-
Notifications
You must be signed in to change notification settings - Fork 378
Fix Nav Flyout Accessibility #8279
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
Merged
tlabaj
merged 15 commits into
patternfly:main
from
ruibrii:7781-nav-flyout-accessibility
Dec 8, 2022
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
91d7907
fix(NavItem): disallow flyout and link props to both be defined on Na…
ruibrii 2020766
docs(Navigation): remove links from NavItems with flyouts
ruibrii cb472c7
Merge branch 'patternfly:main' into 7781-nav-flyout-accessibility
ruibrii 9d09055
Merge branch 'patternfly:main' into 7781-nav-flyout-accessibility
ruibrii 06d7d62
fix(NavItem): remove aria-expanded prop
ruibrii 435d2ae
fix(NavItem): use a button for Component if there is a flyout
ruibrii 61aa96f
Merge branch 'patternfly:main' into 7781-nav-flyout-accessibility
ruibrii 1699a7c
fix(NavItem): allow flyout to be opened on pressing Enter
ruibrii af8d64f
fix(MenuItem): disallow flyoutMenu and link props to both be defined
ruibrii 5ec7ea6
docs(Navigation): remove links from MenuItems with flyouts
ruibrii de73623
fix(SelectOption): make props conditional to align with MenuItemProps
ruibrii c8cdd3a
fix(DropdownItem): make props conditional to align with MenuItemProps
ruibrii 5abd569
fix(NavItem): revert conditional prop changes
ruibrii dbcd85b
fix(NavItem): fix opening nested MenuItem-based flyouts with keyboard
ruibrii 3db3fa1
fix(NavItem): add a console.err message if to and flyout are used tog…
ruibrii 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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import { css } from '@patternfly/react-styles'; | |
| import { MenuItemProps, MenuItem } from '../../../components/Menu'; | ||
| import { useOUIAProps, OUIAProps } from '../../../helpers'; | ||
|
|
||
| export interface DropdownItemProps extends Omit<MenuItemProps, 'ref'>, OUIAProps { | ||
| interface CommonDropdownItemProps extends Omit<MenuItemProps, 'ref'>, OUIAProps { | ||
| /** Anything which can be rendered in a dropdown item */ | ||
| children?: React.ReactNode; | ||
| /** Classes applied to root element of dropdown item */ | ||
|
|
@@ -16,6 +16,22 @@ export interface DropdownItemProps extends Omit<MenuItemProps, 'ref'>, OUIAProps | |
| ouiaSafe?: boolean; | ||
| } | ||
|
|
||
| type ConditionalDropdownItemProps = | ||
| | { | ||
| /** Target navigation link */ | ||
| to?: string; | ||
| /** Flyout menu. Disallowed if nav link is defined */ | ||
| flyoutMenu?: never; | ||
| } | ||
| | { | ||
| /** Target navigation link. Disallowed if flyoutMenu is defined */ | ||
| to?: never; | ||
| /** Flyout menu */ | ||
| flyoutMenu?: React.ReactElement; | ||
| }; | ||
|
|
||
| export type DropdownItemProps = CommonDropdownItemProps & ConditionalDropdownItemProps; | ||
|
|
||
|
||
| export const DropdownItem: React.FunctionComponent<MenuItemProps> = ({ | ||
| children, | ||
| className, | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import React from 'react'; | |
| import { css } from '@patternfly/react-styles'; | ||
| import { MenuItemProps, MenuItem } from '../../../components/Menu'; | ||
|
|
||
| export interface SelectOptionProps extends Omit<MenuItemProps, 'ref'> { | ||
| interface CommonSelectOptionProps extends Omit<MenuItemProps, 'ref'> { | ||
| /** Anything which can be rendered in a select option */ | ||
| children?: React.ReactNode; | ||
| /** Classes applied to root element of select option */ | ||
|
|
@@ -19,6 +19,22 @@ export interface SelectOptionProps extends Omit<MenuItemProps, 'ref'> { | |
| isFocused?: boolean; | ||
| } | ||
|
|
||
| type ConditionalSelectOptionProps = | ||
| | { | ||
| /** Target navigation link */ | ||
| to?: string; | ||
| /** Flyout menu. Disallowed if nav link is defined */ | ||
| flyoutMenu?: never; | ||
| } | ||
| | { | ||
| /** Target navigation link. Disallowed if flyoutMenu is defined */ | ||
| to?: never; | ||
| /** Flyout menu */ | ||
| flyoutMenu?: React.ReactElement; | ||
| }; | ||
|
|
||
| export type SelectOptionProps = CommonSelectOptionProps & ConditionalSelectOptionProps; | ||
|
|
||
|
||
| export const SelectOption: React.FunctionComponent<MenuItemProps> = ({ | ||
| children, | ||
| className, | ||
|
|
||
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
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.
@tlabaj Would this change be breaking? I know it's an a11y bug, but I feel like there's a decent chance that there are consumers who followed the example and would need to make changes for the proposed type change here. Also I know that we have the beta tag on
flyoutMenu, but we don't have it onto.Genuine question as I'm not sure. A conditional type like this is a really neat idea though.
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.
Another thing that was noticed in our React huddle is that by doing this the to and flyoutMenu props are no longer rendered in the props table on the React page for the component. If anything, perhaps we can put the implementation proposed here on the backburner and discuss it further down the line?
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.
yes. This would be a breaking change.
I would probably not recommend defining type this way and instead have 2 separate types and a prop that could be one or the other.
We would need to wait for the breaking change release to do this.