Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE11: Autocomplete with dropdown and multiple selection requires doubleclick #1316

Closed
mertsincan opened this issue Apr 13, 2020 · 0 comments
Closed
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@mertsincan
Copy link
Member

Test;

import React, { useState } from 'react';
import './App.css';
import { AutoComplete } from 'primereact/autocomplete';

import 'primereact/resources/themes/nova-light/theme.css';
import 'primereact/resources/primereact.min.css';
import 'primeicons/primeicons.css';

const App = (props) => {

  if(!String.prototype.startsWith) {
    String.prototype.startsWith = function (searchString, position) {
      position = position || 0;
      return this.substr(position, searchString.length) === searchString;
    };
  }

  const [value,] = useState([
    { label: "a", value: "a" },
    { label: "b", value: "b" }
  ]);

  const [values,] = useState([
    { label: "a", value: "a" },
    { label: "b", value: "b" },
    { label: "c", value: "c" }
  ]);

  // Values that match the input for Autocomplete, does not contain already selected Values
  const [filtered, setFiltered] = React.useState();

  /**
   * Called when a User types into the TextInput, sets the filtered Array to the suggestions matching the querystring.
   * Ignores suggestions already included in values
   * @param event Current QueryString
   */
  const onInput = (event) => {
    let results = values.filter((suggestion) => {
      return suggestion.label
        && suggestion.label.toLowerCase().startsWith(event.query.toLowerCase())
        && !value.some(x => x.value === suggestion.value);
    });
    setFiltered(results);
  }

  return (
    <div className="App">
      <AutoComplete
        value={value}
        suggestions={filtered}
        completeMethod={onInput}
        field={"label"}
        multiple={true}
        onChange={e => console.log(e)}
        className={"id-acom-chips"}
        dropdown={true} />
    </div>
  );
}

export default App;
@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label Apr 13, 2020
@mertsincan mertsincan self-assigned this Apr 13, 2020
@mertsincan mertsincan added this to the 4.1.3 milestone Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

1 participant