"closeOnSelection" property(Multiple selection out of box)
See original GitHub issueI want to propose new Prop named closeOnSelection
.
What happened, Problem description:
This codesandbox-example(Your Multi-select example with latest Downshift version) contains hardcoded solution: Menu doesn’t close(as it were), it open after close. Because of this, the highlightedIndex
is reset; as well as existence of a lot of handlers that just control the state of isOpen
.
Suggested solution:
defaultProps = {
// ...
closeOnSelection: true,
// ...
}
selectItem = (item, otherStateToSet, cb) => {
otherStateToSet = pickState(otherStateToSet)
this.internalSetState(
{
...this.props.closeOnSelection
? {
isOpen: false,
highlightedIndex: this.props.defaultHighlightedIndex,
}
: {},
selectedItem: item,
inputValue:
this.isControlledProp('selectedItem') &&
this.props.breakingChanges.resetInputOnSelection
? this.props.defaultInputValue
: this.props.itemToString(item),
...otherStateToSet,
},
(...args) => {
this.focusInput()
typeof cb === 'function' && cb(...args)
},
)
}
!NOTE: At now this will work fine only for the case with Input
element, because it’s focusing after select.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Select 2 Multi Select remove option from the dropdown after ...
I am using Jquery Select2 to have Multiselect with Checkbox. I want to remove the selected Item from the dropdown.
Read more >MultiSelect Property - Microsoft Support
You can use the MultiSelect property to specify whether a user can make multiple selections in a list box on a form and...
Read more >Options | Select2 - The jQuery replacement for select boxes
Option Type Default
ajax object null
allowClear boolean false
amdLanguageBase string./i18n/
Read more >Select2 3.5.3
When placeholder is used for a non-multi-value select box, ... The default implementation expects the object to have a id property that is...
Read more >Angular 10|9|8 NgSelect with Single/ Multiple Selection and ...
bindLabel : The property of an object which we want to show as a label in a select box. placeholder : Text shown...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, i can. Of course, different. I’ll start a little bit later(in 2-3 hours). Thanks for support!
Loving the ideas coming here. Thank you!