-
Notifications
You must be signed in to change notification settings - Fork 833
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
Add closeOnSelect prop to SelectMenu #588
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,17 @@ export default class OptionsList extends PureComponent { | |
*/ | ||
isMultiSelect: PropTypes.bool, | ||
|
||
/** | ||
* When true, menu closes on option selection. | ||
*/ | ||
closeOnSelect: PropTypes.bool, | ||
|
||
/** | ||
* This holds the values of the options | ||
*/ | ||
selected: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), | ||
selected: PropTypes.arrayOf( | ||
PropTypes.oneOfType([PropTypes.string, PropTypes.number]) | ||
), | ||
onSelect: PropTypes.func, | ||
onDeselect: PropTypes.func, | ||
onFilterChange: PropTypes.func, | ||
|
@@ -201,6 +208,9 @@ export default class OptionsList extends PureComponent { | |
|
||
handleSelect = item => { | ||
this.props.onSelect(item) | ||
if (!this.props.isMultiSelect && this.props.closeOnSelect) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized that hitting the @mshwery - would love some thoughts! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could save that for a separate PR if the current behavior is problematic. I think it's fine to leave alone for now TBH, though I agree with your idea! |
||
this.props.close() | ||
} | ||
} | ||
|
||
handleDeselect = item => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you configure your editor? I don't think these lines should be formatted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using VS Code. It's picking up the prettier settings in the
package.json
and as there is noprintWidth
setting is going with the default of 80. This line is longer than that, which is why it is being formatted.I've left it as is as the prettier settings would need to explicitly state a larger
printWidth
. Is this ok? Would you rather I change it back?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. Maybe nobody had touched the file in a while. Thanks for checking!