-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[AutoComplete] Fix first item selection on keyboard focus #3867
[AutoComplete] Fix first item selection on keyboard focus #3867
Conversation
Thanks for recreating the PR. |
@viniciusdacal I haven't noticed any issue with the component. That looks good 👍. |
7a08927
to
206fbad
Compare
@@ -242,6 +248,7 @@ class Menu extends React.Component { | |||
this.setState({ | |||
focusIndex: nextProps.disableAutoFocus ? -1 : selectedIndex >= 0 ? selectedIndex : 0, | |||
keyWidth: nextProps.desktop ? 64 : 56, | |||
isKeyboardFocused: nextProps.keyboardFocused || this.state.isKeyboardFocused, |
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.
What if nextProps.keyboardFocused = false
and this.state.isKeyboardFocused = true
😁?
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.
Good question 😄
Do you think we could use only nextProps.keyboardFocused
here?
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.
We could use something like:
isKeyboardFocused: nextProps.keyboardFocused !== null ? nextProps.keyboardFocused : this.state.isKeyboardFocused
206fbad
to
666874e
Compare
@oliviertassinari pr updated. |
@viniciusdacal Thanks. |
@oliviertassinari make sense for me use |
@viniciusdacal Yes please 👯. |
Great. |
Don't worry, no need to rush things :). On Thu, 7 Apr 2016 19:22 Vinicius Dacal Lopes, notifications@github.com
|
666874e
to
90fb007
Compare
@@ -224,7 +230,7 @@ class Menu extends React.Component { | |||
|
|||
this.state = { | |||
focusIndex: props.disableAutoFocus ? -1 : selectedIndex >= 0 ? selectedIndex : 0, | |||
isKeyboardFocused: props.initiallyKeyboardFocused, | |||
isKeyboardFocused: props.keyboardFocused !== null ? props.keyboardFocused : props.initiallyKeyboardFocused, |
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.
@oliviertassinari updated 😄
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.
Unless I'm missing something -- can that be shortened to props.keyboardFocused || props.initiallyKeyboardFocused
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.
if we set prop keyboardFocused
as false, isKeyboardFocused
should be false, even if initiallyKeyboardFocused
is true
@viniciusdacal I have just realized that we can fix the issue with a single line diff commit: -initiallyKeyboardFocused={false}
+initiallyKeyboardFocused={true} No need for an extra |
@oliviertassinari I will change to check, but I think this way it will be focused instantly when the menu open, and not only on keydown. |
@viniciusdacal - what did you find? |
@mbrookes I was very busy in the last weeks, but I'm gonna use this weekend to solve this. |
On hold pending review of alternate fix. |
This fix first item selection at autocomplete popover, described at #3629.
If you type 'a' in the input, and hit down arrow to select the first item, you don't see the selection, if you press again, the second item will be selected.
http://www.material-ui.com/#/components/auto-complete
Fixes #3629.