MultiInput preselected options
sushiljain1989 opened this issue · 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.
Hello @sushiljain1989, thank you for using fundamental-react! The fundamental-react team will triage your issue as soon as possible.
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} />;
}