question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"closeOnSelection" property(Multiple selection out of box)

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
pas1kocommented, Jan 30, 2018

Yes, i can. Of course, different. I’ll start a little bit later(in 2-3 hours). Thanks for support!

0reactions
kentcdoddscommented, Jan 30, 2018

Loving the ideas coming here. Thank you!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found