From 274d7f72f7ea8b0a46c8b7a2ff8da8c7f749aa43 Mon Sep 17 00:00:00 2001 From: boaz0 Date: Mon, 28 Jan 2019 18:35:02 +0200 Subject: [PATCH] fix(Page): improve a11y in sidebar and header (#1145) Signed-off-by: Boaz Shuster --- .../src/components/Page/PageHeader.d.ts | 1 + .../react-core/src/components/Page/PageHeader.js | 14 +++++++++++--- .../src/components/Page/PageSidebar.js | 5 +++-- .../Page/__snapshots__/Page.test.js.snap | 16 +++++++++++++--- .../Page/__snapshots__/PageHeader.test.js.snap | 2 ++ .../src/components/Page/examples/VerticalPage.js | 1 + .../PageLayout/examples/PageLayoutDefaultNav.js | 1 + .../examples/PageLayoutExpandableNav.js | 1 + .../PageLayout/examples/PageLayoutGroupsNav.js | 1 + .../PageLayout/examples/PageLayoutSimpleNav.js | 1 + 10 files changed, 35 insertions(+), 8 deletions(-) diff --git a/packages/patternfly-4/react-core/src/components/Page/PageHeader.d.ts b/packages/patternfly-4/react-core/src/components/Page/PageHeader.d.ts index a4e609d210b..fbd5da942d0 100644 --- a/packages/patternfly-4/react-core/src/components/Page/PageHeader.d.ts +++ b/packages/patternfly-4/react-core/src/components/Page/PageHeader.d.ts @@ -8,6 +8,7 @@ export interface PageHeaderProps extends HTMLProps { avatar?: ReactNode; topNav?: ReactNode; showNavToggle?: boolean; + isNavOpen?: boolean; onNavToggle?: Function; } diff --git a/packages/patternfly-4/react-core/src/components/Page/PageHeader.js b/packages/patternfly-4/react-core/src/components/Page/PageHeader.js index f33d286bdea..6d452f49656 100644 --- a/packages/patternfly-4/react-core/src/components/Page/PageHeader.js +++ b/packages/patternfly-4/react-core/src/components/Page/PageHeader.js @@ -20,8 +20,12 @@ const propTypes = { topNav: PropTypes.node, /** True to show the nav toggle button (toggles side nav) */ showNavToggle: PropTypes.bool, + /** True if the side nav is shown */ + isNavOpen: PropTypes.bool, /** Callback function to handle the side nav toggle button */ onNavToggle: PropTypes.func, + /** Callback function to handle the side nav toggle button */ + 'aria-label': PropTypes.string, /** Additional props are spread to the container
*/ '': PropTypes.any }; @@ -34,10 +38,12 @@ const defaultProps = { avatar: null, topNav: null, showNavToggle: false, - onNavToggle: () => undefined + isNavOpen: true, + onNavToggle: () => undefined, + 'aria-label': "Toggle global navigation", }; -const PageHeader = ({ className, logo, logoProps, toolbar, avatar, topNav, showNavToggle, onNavToggle, ...props }) => ( +const PageHeader = ({ className, logo, logoProps, toolbar, avatar, topNav, isNavOpen, showNavToggle, onNavToggle, 'aria-label': ariaLabel, ...props }) => (
{showNavToggle && ( @@ -45,7 +51,9 @@ const PageHeader = ({ className, logo, logoProps, toolbar, avatar, topNav, showN
); PageSidebar.propTypes = propTypes; diff --git a/packages/patternfly-4/react-core/src/components/Page/__snapshots__/Page.test.js.snap b/packages/patternfly-4/react-core/src/components/Page/__snapshots__/Page.test.js.snap index 36a8bccb902..239688af8a5 100644 --- a/packages/patternfly-4/react-core/src/components/Page/__snapshots__/Page.test.js.snap +++ b/packages/patternfly-4/react-core/src/components/Page/__snapshots__/Page.test.js.snap @@ -77,8 +77,10 @@ exports[`Check page horizontal layout example against snapshot 1`] = ` className="my-page-class" header={ -