ComboBox: Option to use ariaLabel prop as preview text#4540
Merged
jspurlin merged 8 commits intomicrosoft:masterfrom Apr 13, 2018
Merged
ComboBox: Option to use ariaLabel prop as preview text#4540jspurlin merged 8 commits intomicrosoft:masterfrom
jspurlin merged 8 commits intomicrosoft:masterfrom
Conversation
Updating fork
merging master
Merge master into kysedate fork
…t. This is necessary for cases where embedded text is used as the option text
jspurlin
reviewed
Apr 13, 2018
|
|
||
| // If autoComplete is on, attempt to find a match where the text of an option starts with the updated value | ||
| const items = currentOptions.map((item, index) => { return { ...item, index }; }).filter((option) => option.itemType !== SelectableOptionMenuItemType.Header && option.itemType !== SelectableOptionMenuItemType.Divider).filter((option) => option.text.toLocaleLowerCase().indexOf(updatedValue) === 0); | ||
| const items = currentOptions.map((item, index) => { return { ...item, index }; }).filter((option) => option.itemType !== SelectableOptionMenuItemType.Header && option.itemType !== SelectableOptionMenuItemType.Divider).filter((option) => this._getPreviewText(option).toLocaleLowerCase().indexOf(updatedValue) === 0); |
Contributor
There was a problem hiding this comment.
This line is really long, consider breaking it up across multiple line
jspurlin
reviewed
Apr 13, 2018
|
|
||
| // If autoComplete is off, attempt to find a match only when the value is exactly equal to the text of an option | ||
| const items = currentOptions.map((item, index) => { return { ...item, index }; }).filter((option) => option.itemType !== SelectableOptionMenuItemType.Header && option.itemType !== SelectableOptionMenuItemType.Divider).filter((option) => option.text.toLocaleLowerCase() === updatedValue); | ||
| const items = currentOptions.map((item, index) => { return { ...item, index }; }).filter((option) => option.itemType !== SelectableOptionMenuItemType.Header && option.itemType !== SelectableOptionMenuItemType.Divider).filter((option) => this._getPreviewText(option).toLocaleLowerCase() === updatedValue); |
jspurlin
reviewed
Apr 13, 2018
| role='option' | ||
| aria-selected={ isSelected ? 'true' : 'false' } | ||
| ariaLabel={ item.text } | ||
| ariaLabel={ this._getPreviewText(item) } |
Contributor
There was a problem hiding this comment.
What about the multiSelect case?
Contributor
Author
There was a problem hiding this comment.
I'm not sure what you mean..
Contributor
There was a problem hiding this comment.
the checkbox below seems to be missing the ariaLabel... we should fix that
jspurlin
reviewed
Apr 13, 2018
| styles?: Partial<IComboBoxOptionStyles>; | ||
|
|
||
| /** | ||
| * In scenarios where embedded data is used at the text prop, we will use the ariaLabel prop to set the aria-label and preview text. Default to false |
Contributor
There was a problem hiding this comment.
NIT: wrap this to multiple lines as well
ddlbrena
reviewed
Apr 13, 2018
| return retKeys; | ||
| } | ||
|
|
||
| private _getPreviewText(item: IComboBoxOption): string { |
Contributor
There was a problem hiding this comment.
this seems like a good place to add a comment explaining why are we doing this
jspurlin
approved these changes
Apr 13, 2018
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request checklist
$ npm run changeDescription of changes
There are scenarios where the text passed into a ComboBox option isn't plain text, but rather text with an embedded style. In this case, we want to render a plain text version of the string on the aria-label of the option, in the ComboBox input when selected, and used for that option's autocomplete string. This prop allows for the ComboBox to handle this case by using the ariaLabel prop instead of the text prop when necessary.