From 9de67763d2237ba6125e79546acabecf465b60eb Mon Sep 17 00:00:00 2001 From: Boaz Shuster Date: Mon, 7 Jan 2019 23:38:32 +0200 Subject: [PATCH] fix(Page): improve a11y in sidebar and header Signed-off-by: Boaz Shuster --- .../react-core/src/components/Page/PageHeader.d.ts | 1 + .../react-core/src/components/Page/PageHeader.js | 9 +++++++-- .../react-core/src/components/Page/PageSidebar.js | 5 +++-- .../components/Page/__snapshots__/Page.test.js.snap | 12 +++++++++--- .../Page/__snapshots__/PageHeader.test.js.snap | 1 + .../src/components/Page/examples/VerticalPage.js | 1 + .../PageLayout/examples/PageLayoutDefaultNav.js | 1 + .../PageLayout/examples/PageLayoutExpandableNav.js | 1 + .../demos/PageLayout/examples/PageLayoutGroupsNav.js | 1 + .../demos/PageLayout/examples/PageLayoutSimpleNav.js | 1 + 10 files changed, 26 insertions(+), 7 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 2c431245325..315f722ab0b 100644 --- a/packages/patternfly-4/react-core/src/components/Page/PageHeader.js +++ b/packages/patternfly-4/react-core/src/components/Page/PageHeader.js @@ -20,6 +20,8 @@ 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 }; @@ -32,10 +34,11 @@ const defaultProps = { avatar: null, topNav: null, showNavToggle: false, + isNavOpen: true, onNavToggle: () => undefined }; -const PageHeader = ({ className, logo, logoProps, toolbar, avatar, topNav, showNavToggle, onNavToggle, ...props }) => ( +const PageHeader = ({ className, logo, logoProps, toolbar, avatar, topNav, isNavOpen, showNavToggle, onNavToggle, ...props }) => (
{showNavToggle && ( @@ -43,7 +46,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..e1f765263f0 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 @@ -79,6 +79,7 @@ exports[`Check page horizontal layout example against snapshot 1`] = ` -