-
Notifications
You must be signed in to change notification settings - Fork 110
fix(ui-top-nav-bar,ui-drilldown): fix Drilldown's and TopNavBar's key… #1975
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 all commits
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 |
|---|---|---|
|
|
@@ -648,12 +648,10 @@ class PlaygroundExample extends React.Component { | |
|
|
||
| {...item.submenu && { | ||
| renderSubmenu: this.generateSubmenu(item), | ||
| 'aria-label': `Open for ${item.label} menu` | ||
|
Contributor
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. Réka said aria-label is unnecessary hin these places and advised to remove them |
||
| }} | ||
|
|
||
| {...item.customPopoverConfig && { | ||
| customPopoverConfig: item.customPopoverConfig, | ||
| 'aria-label': `Open for ${item.label} menu` | ||
| }} | ||
|
|
||
| {...!item.submenu && !item.customPopoverConfig ? { | ||
|
|
@@ -720,7 +718,7 @@ class PlaygroundExample extends React.Component { | |
| <TopNavBar.Item | ||
| id="Info" | ||
| renderIcon={<IconQuestionLine />} | ||
| aria-label="Open for info menu" | ||
| aria-label="info menu" | ||
| renderSubmenu={this.generateSubmenu({ | ||
| id: 'Info', | ||
| submenu: ['Contact', 'Map', 'Career'].map(item => ({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,10 +66,9 @@ const generateStyle = ( | |
| alignItems: 'stretch', | ||
| justifyContent: 'space-between', | ||
| height: componentTheme.desktopHeight, | ||
| position: 'relative', | ||
|
Contributor
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. these positions and overflows needed to be modified now that Drilldown is no longer mounted to the end of the document, otherwise the styling breaks |
||
| zIndex: componentTheme.desktopZIndex, | ||
| maxWidth: '100%', | ||
| overflow: 'hidden', | ||
| overflow: 'visible', | ||
| paddingInline: componentTheme.desktopInlinePadding, | ||
| paddingBlock: 0, | ||
| ...(hasBrandBlock && { | ||
|
|
@@ -113,7 +112,6 @@ const generateStyle = ( | |
| marginInline: componentTheme.desktopUserContainerInlineMargin, | ||
|
|
||
| ...(hasUserSeparator && { | ||
| position: 'relative', | ||
| paddingInlineStart: componentTheme.desktopUserSeparatorGap, | ||
|
|
||
| '&::before': { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,6 +104,7 @@ class TopNavBarSmallViewportLayout extends Component< | |
| private readonly _inPlaceDialogId: string | ||
| private readonly _inPlaceDialogCloseButtonId: string | ||
| private readonly _separatorId: string | ||
| private _drilldownRef: Drilldown | null = null | ||
|
|
||
| private _raf: RequestAnimationFrameType[] = [] | ||
|
|
||
|
|
@@ -286,7 +287,44 @@ class TopNavBarSmallViewportLayout extends Component< | |
| onDropdownMenuToggle(!isDropdownMenuOpen) | ||
| } | ||
|
|
||
| this.setState({ isDropdownMenuOpen: !isDropdownMenuOpen }) | ||
| this.setState( | ||
| { isDropdownMenuOpen: !this.state.isDropdownMenuOpen }, | ||
| () => { | ||
| if (this.state.isDropdownMenuOpen) { | ||
| this.focusFirstAvailableItem() | ||
| } | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| focusFirstAvailableItem() { | ||
| const userChildren = Children.toArray( | ||
| this.props.renderUser?.props.children | ||
| ) as ItemChild[] | ||
|
|
||
| // If option is a User, it preceeds other item, so focus that first | ||
| const targetId = userChildren[0] | ||
| ? userChildren[0].props.id | ||
| : this.mappedMenuItemsOptions[0].optionData.id | ||
|
|
||
| setTimeout(() => { | ||
| const container = document.getElementById(this._trayContainerId) | ||
| const firstOption = container?.querySelector( | ||
| `[id="${targetId}"]` | ||
| ) as HTMLSpanElement | ||
| firstOption?.focus() | ||
| if (this._drilldownRef) { | ||
| const drilldownRef = this._drilldownRef | ||
| setTimeout(() => { | ||
| if (drilldownRef) { | ||
| // highlight the option using Drilldown's handleOptionHighlight function | ||
| drilldownRef.handleOptionHighlight({} as React.SyntheticEvent, { | ||
| id: targetId | ||
| }) | ||
| } | ||
| }, 10) | ||
| } | ||
| }, 10) | ||
| } | ||
|
|
||
| renderOptionContent: RenderOptionContent = (children, itemProps) => { | ||
|
|
@@ -402,6 +440,9 @@ class TopNavBarSmallViewportLayout extends Component< | |
| return ( | ||
| <div css={styles?.menuTriggerContainer}> | ||
| {menuTrigger} | ||
| {!this.hasBreadcrumbBlock && !this.props.trayMountNode && ( | ||
| <div css={styles?.trayContainer} id={this._trayContainerId} /> | ||
| )} | ||
|
|
||
| {this.hasBrandBlock(renderBrand) && !alternativeTitle && ( | ||
| <div css={styles?.brandContainer}>{renderBrand}</div> | ||
|
|
@@ -442,6 +483,9 @@ class TopNavBarSmallViewportLayout extends Component< | |
|
|
||
| return ( | ||
| <Drilldown | ||
| ref={(el) => { | ||
| this._drilldownRef = el | ||
| }} | ||
| id={this._drilldownId} | ||
| rootPageId={this._menuId} | ||
| label={dropdownMenuLabel} | ||
|
|
@@ -576,13 +620,7 @@ class TopNavBarSmallViewportLayout extends Component< | |
| } | ||
|
|
||
| render() { | ||
| const { | ||
| trayMountNode, | ||
| navLabel, | ||
| renderActionItems, | ||
| renderBreadcrumb, | ||
| styles | ||
| } = this.props | ||
| const { navLabel, renderActionItems, renderBreadcrumb, styles } = this.props | ||
|
|
||
| return ( | ||
| <nav | ||
|
|
@@ -607,10 +645,6 @@ class TopNavBarSmallViewportLayout extends Component< | |
|
|
||
| {!this.hasBreadcrumbBlock && this.renderInPlaceDialog()} | ||
|
|
||
| {!this.hasBreadcrumbBlock && !trayMountNode && ( | ||
| <div css={styles?.trayContainer} id={this._trayContainerId} /> | ||
| )} | ||
|
|
||
|
Comment on lines
610
to
613
Contributor
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. I moved this code after line 466 so that when I'm on the first item of the drill-down menu with SR and step back, the focus returns to the Drilldown's trigger, thereby exiting the DrillDown. |
||
| {!this.hasBreadcrumbBlock && this.renderDropdownMenuTray()} | ||
| </nav> | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
This solution is based on mounting the DrillDown to the component (not to document.body), allowing us to navigate back from the first item to the trigger button itself.
Uh oh!
There was an error while loading. Please reload this page.
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 should mention this in the release notes, it might break stuff for users