Last active
September 2, 2017 03:53
-
-
Save george-aidonidis/0ce376a0f30f60e54616e6cef468ece5 to your computer and use it in GitHub Desktop.
Grommet select onEnter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_onEnter (event) { | |
const { onChange, options } = this.props; | |
const { activeOptionIndex } = this.state; | |
const { intl } = this.context; | |
event.preventDefault(); // prevent submitting forms | |
const option = options[activeOptionIndex >= 0 ? activeOptionIndex : 0]; | |
const value = this._valueForSelectedOption(option); | |
this.setState({ dropActive: false, value }, () => { | |
const optionMessage = this._renderLabel(option); | |
const selectedMessage = Intl.getMessage(intl, 'Selected'); | |
announce(`${optionMessage} ${selectedMessage}`); | |
}); | |
if (onChange) { | |
onChange({ target: this.inputRef, option, value }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment