This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
[terra-menu] - Fixed SR not announcing menu group name information. #1841
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4e78ac7
Fixed SR not announcing group information
PK106552 f6dfab4
Updated review comments
PK106552 bae1255
Fixed lint error
PK106552 38e33c4
Updated doc file
PK106552 e1446e9
Updated review comments
PK106552 af27824
fixed review comment
PK106552 37d673e
Updated review comments
PK106552 bd61f5c
lint error
PK106552 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,7 @@ class MenuContent extends React.Component { | |
this.onKeyDown = this.onKeyDown.bind(this); | ||
this.onKeyDownBackButton = this.onKeyDownBackButton.bind(this); | ||
this.validateFocus = this.validateFocus.bind(this); | ||
this.ariaDescribedByHandle = this.ariaDescribedByHandle.bind(this); | ||
this.needsFocus = props.isFocused; | ||
this.handleContainerRef = this.handleContainerRef.bind(this); | ||
this.menuHeaderId = `terra-menu-headertitle-${uuidv4()}`; | ||
|
@@ -342,6 +343,14 @@ class MenuContent extends React.Component { | |
); | ||
} | ||
|
||
ariaDescribedByHandle(value, index) { | ||
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 function can be simplified to ariaDescribedByHandle(value, index) {
if (!MenuUtils.isMac() && !this.props.index && this.props.showHeader && index === 0) {
let ariaDescribedByValue = (value.props.ariaDescribedBy) ? `, ${value.props.ariaDescribedBy}` : '';
return `${this.menuTopHeaderId}${ariaDescribedByValue}`;
}
return value.props.ariaDescribedBy;
} 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. Updated - 37d673e |
||
if (!MenuUtils.isMac() && !this.props.index && this.props.showHeader && index === 0) { | ||
const ariaDescribedByValue = (value.props.ariaDescribedBy) ? ` ${value.props.ariaDescribedBy}` : ''; | ||
return `${this.menuTopHeaderId}${ariaDescribedByValue}`; | ||
} | ||
return value.props.ariaDescribedBy; | ||
} | ||
|
||
render() { | ||
let index = -1; | ||
const totalItems = MenuUtils.totalItems(this.props.children); | ||
|
@@ -356,28 +365,29 @@ class MenuContent extends React.Component { | |
index += 1; | ||
const onKeyDown = this.wrapOnKeyDown(item, index, item.props.isDisabled); | ||
const isActive = this.state.focusIndex === index; | ||
|
||
const ariaDescribedByHandleValue = this.ariaDescribedByHandle(item, index); | ||
newItem = React.cloneElement(item, { | ||
onClick, | ||
onKeyDown, | ||
isActive, | ||
totalItems, | ||
index, | ||
intl: this.props.intl, | ||
'aria-describedby': !MenuUtils.isMac() && !this.props.index && this.props.showHeader && index === 0 ? this.menuTopHeaderId : undefined, | ||
'aria-describedby': ariaDescribedByHandleValue, | ||
}); | ||
// If the child has children then it is an item group, so iterate through it's children | ||
} else if (item.props.children) { | ||
const children = item.props.children ? [] : undefined; | ||
React.Children.forEach(item.props.children, (child) => { | ||
index += 1; | ||
const ariaDescribedByHandleValue = this.ariaDescribedByHandle(child, index); | ||
const clonedElement = React.cloneElement(child, { | ||
onKeyDown: this.wrapOnKeyDown(child, index, child.props.isDisabled), | ||
isActive: index === this.state.focusIndex, | ||
totalItems, | ||
index, | ||
intl: this.props.intl, | ||
'aria-describedby': !MenuUtils.isMac() && !this.props.index && this.props.showHeader && index === 0 ? this.menuTopHeaderId : undefined, | ||
'aria-describedby': ariaDescribedByHandleValue, | ||
}); | ||
children.push(clonedElement); | ||
}); | ||
|
Oops, something went wrong.
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.
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.
I think we still need this prop along with this prop we need to create a prop for GroupId so that it can be used in menu item for
aria-describedby
attribute.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.
Updated - 4cf4469