-
Notifications
You must be signed in to change notification settings - Fork 283
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
improve UX of dropdown inputs #2774
improve UX of dropdown inputs #2774
Conversation
Signed-off-by: aporss <[email protected]>
{...(this.props.stateReducer !== undefined && { | ||
stateReducer: (state, changes) => this.props.stateReducer(state, changes) | ||
})} | ||
defaultHighlightedIndex={0} |
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.
first item in dropdown is highlighted by default allowing to select the item by pressing Enter on the keyboard
stateReducer={(state, changes)=>{ | ||
// keep input changes when user clicks outside input | ||
if(changes.type && (changes.type === Downshift.stateChangeTypes.mouseUp | ||
|| changes.type === Downshift.stateChangeTypes.blurInput)) { | ||
changes.inputValue = state.inputValue; | ||
} | ||
return changes; | ||
}} |
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.
when input is defocused, input contents are not deleted anymore
@@ -345,16 +346,19 @@ class InputDropdown extends React.Component { | |||
initialSelectedItem={defaultSelectedItem} | |||
inputValue={this.props.value} | |||
itemToString={this.props.itemToString} | |||
onChange={(selected) => this.props.onChange(selected)} | |||
onSelect={(selected) => this.props.onChange(selected)} // onSelect seem to trigger more consistently than onChange |
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.
using onSelect instead of onChange because it triggered more consistently during functional tests
@@ -38,6 +39,7 @@ const Icon = (props) => { | |||
onClick={props.onClick} | |||
ref={props.innerRef} | |||
data-testid='icon' | |||
data-wdio={dataWdio} |
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.
for use in functional tests
Description
Improves UX of inputs that use a dropdown. This includes:
Changes cover:
Contribution Checklist: