fundamental-react icon indicating copy to clipboard operation
fundamental-react copied to clipboard

MultiInput preselected options

Open sushiljain1989 opened this issue 4 years ago • 2 comments

Description

I want to pass the list of selected options in props but I don't see an option for that. If I am missing something or the functionality itself is missing>

Versions

fundamental-react:

0.13.1 NOTE: Where applicable, please include uncropped screen captures.

DISCLAIMER: After triaging an issue, the fundamental-react team will see if it can be reproduced or confirmed. If more information is needed, the fundamental-react team will contact the author. Any issues awaiting responses from the author for more than 7 days will be closed. The author can re-open the issue at a later time if they can present the requested information.

sushiljain1989 avatar Jan 13 '21 11:01 sushiljain1989

Hello @sushiljain1989, thank you for using fundamental-react! The fundamental-react team will triage your issue as soon as possible.

github-actions[bot] avatar Jan 13 '21 11:01 github-actions[bot]

I'm having the same problem. A fully controlled component would be nice. I'm currently using this workaround which is super hacky:

function Parent() {
  const [selectedItems, setSelectedItems] = useState<string[]>([]);
  const multiInputRef = React.useRef<MultiInput>();

  React.useEffect(() => {
    multiInputRef.current?.setState({ tags: selectedItems });
  }, [selectedItems]);

  return <MultiInput ref={multiInputRef} onTagsUpdate={setSelectedItems} />;
}

Jonasdoubleyou avatar Mar 08 '21 20:03 Jonasdoubleyou