-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fixes duplicate reading of suggestions on people picker #4765
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
Changes from 7 commits
2797c1d
451279a
d88c280
083aacf
11d1f3c
44d046a
18e8c63
06d9391
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "Puts additional alert on selected suggestions behind a prop", | ||
| "type": "minor" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "rebeba@microsoft.com" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,10 +175,15 @@ export class BasePicker<T, P extends IBasePickerProps<T>> extends BaseComponent< | |
| } = this.props; | ||
|
|
||
| const currentIndex = this.suggestionStore.currentIndex; | ||
| const selectedSuggestion = currentIndex > -1 ? this.suggestionStore.getSuggestionAtIndex(this.suggestionStore.currentIndex) : undefined; | ||
| const selectedSuggestionAlert = selectedSuggestion ? selectedSuggestion.ariaLabel : undefined; | ||
| const activeDescendant = currentIndex > -1 ? 'sug-' + currentIndex : undefined; | ||
|
|
||
| let selectedSuggestionAlert = undefined; | ||
| if (this.props.enableSelectedSuggestionAlert) { | ||
| const selectedSuggestion = currentIndex > -1 ? this.suggestionStore.getSuggestionAtIndex(this.suggestionStore.currentIndex) : undefined; | ||
| const selectedSuggestionAlertText = selectedSuggestion ? selectedSuggestion.ariaLabel : undefined; | ||
| selectedSuggestionAlert = (<div className={ styles.screenReaderOnly } role='alert' id='selected-suggestion-alert' aria-live='assertive'>{ selectedSuggestionAlertText } </div>); | ||
|
Contributor
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. Why is this element assertive while the one below is polite, shouldn't they be the same? (Polite seems like the correct level to use here)
Author
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. For IE. The only reason this alert exists at all is for IE, and in traditional IE fashion, it does not read unless it is set to "assertive". Definitely agree that polite seems like the correct level here, but since this alert was created so it would work in IE, we need it to be assertive.
Contributor
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. Okay, in that case should the live region below also use assertive? |
||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| ref={ this.root } | ||
|
|
@@ -192,7 +197,7 @@ export class BasePicker<T, P extends IBasePickerProps<T>> extends BaseComponent< | |
| direction={ FocusZoneDirection.bidirectional } | ||
| isInnerZoneKeystroke={ this._isFocusZoneInnerKeystroke } | ||
| > | ||
| <div className={ styles.screenReaderOnly } role='alert' id='selected-suggestion-alert' aria-live='assertive'>{ selectedSuggestionAlert } </div> | ||
| { selectedSuggestionAlert } | ||
| <SelectionZone selection={ this.selection } selectionMode={ SelectionMode.multiple }> | ||
| <div className={ css('ms-BasePicker-text', styles.pickerText, this.state.isFocused && styles.inputFocused) } role={ 'list' }> | ||
| { this.renderItems() } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,6 +135,13 @@ export interface IBasePickerProps<T> extends React.Props<any> { | |
| * A callback to override the default behavior of adding the selected suggestion on dismiss. | ||
| */ | ||
| onDismiss?: (ev?: any, selectedItem?: T) => void; | ||
| /** | ||
| * Adds an additional alert for the currently selected suggestion. This prop should be set to true for IE11 and below, as it | ||
| * enables proper screen reader behavior for each suggestion (since aria-activedescendant does not work with IE11). | ||
| * It should not be set for modern browsers (Edge, Chrome). | ||
| * @default false | ||
| */ | ||
| enableSelectedSuggestionAlert?: boolean; | ||
|
Contributor
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. Doesn't this essentially make it a breaking change for IE 11? Since by default it's false, anything that's consuming it won't know to have a check for IE11 and won't pass through the variable, so screen readers won't read it properly. @dzearing and @cliffkoh should the picker check for ie 11 itself maybe?
Author
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. This does break IE 11, but it fixes Chrome and Edge. Do we have browser detection logic in fabric? Would love to not even have a new prop needed here.
Member
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 it's worth the breaking change, because this makes host apps aware of the issue. |
||
| } | ||
|
|
||
| export interface IBasePickerSuggestionsProps { | ||
|
|
||
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.
More of just a general point, we should really have a screen reader component or something that does this and handles all those attributes so we can have them standardized. @cliffkoh or @dzearing what do you think about that?