Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-core/src/components/Page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class Page extends Component<PageProps, PageState> {
isManagedSidebar,
onSidebarToggle: mobileView ? this.onSidebarToggleMobile : this.onSidebarToggleDesktop,
isSidebarOpen: mobileView ? mobileIsSidebarOpen : desktopIsSidebarOpen,
isMobile: mobileView,
width,
height,
getBreakpoint,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-core/src/components/Page/PageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface PageContextProps {
isManagedSidebar: boolean;
onSidebarToggle: () => void;
isSidebarOpen: boolean;
isMobile: boolean;
width: number;
height: number;
getBreakpoint: (width: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
Expand All @@ -16,6 +17,7 @@ export const pageContextDefaults: PageContextProps = {
isManagedSidebar: false,
isSidebarOpen: false,
onSidebarToggle: () => null,
isMobile: false,
width: null,
height: null,
getBreakpoint,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-core/src/components/Page/PageSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ export const PageSidebar: React.FunctionComponent<PageSidebarProps> = ({
...props
}: PageSidebarProps) => (
<PageContextConsumer>
{({ isManagedSidebar, isSidebarOpen: managedIsNavOpen }: PageSidebarProps) => {
{({ isManagedSidebar, isSidebarOpen: managedIsNavOpen, isMobile }) => {
const sidebarOpen = isManagedSidebar ? managedIsNavOpen : isSidebarOpen;

return (
<div
id={id}
className={css(
styles.pageSidebar,
sidebarOpen && styles.modifiers.expanded,
sidebarOpen && isMobile && styles.modifiers.expanded,
!sidebarOpen && styles.modifiers.collapsed,
className
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`PageSidebar should match snapshot (auto-generated) 1`] = `
<DocumentFragment>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded ''"
class="pf-v6-c-page__sidebar ''"
id="page-sidebar"
>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`Page Check dark page against snapshot 1`] = `
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
>
<div
Expand Down Expand Up @@ -55,7 +55,7 @@ exports[`Page Check page horizontal layout example against snapshot 1`] = `
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -92,7 +92,7 @@ exports[`Page Check page to verify breadcrumb is created - PageBreadcrumb syntax
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -237,7 +237,7 @@ exports[`Page Check page to verify breadcrumb is created 1`] = `
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -386,7 +386,7 @@ exports[`Page Check page to verify grouped nav and breadcrumb - new components s
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -629,7 +629,7 @@ exports[`Page Check page to verify grouped nav and breadcrumb - old / props synt
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -913,7 +913,7 @@ exports[`Page Check page to verify skip to content points to main content region
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -1063,7 +1063,7 @@ exports[`Page Check page vertical layout example against snapshot 1`] = `
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
>
<div
Expand Down Expand Up @@ -1106,7 +1106,7 @@ exports[`Page Sticky bottom breadcrumb on all height breakpoints - PageBreadcrum
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -1251,7 +1251,7 @@ exports[`Page Verify sticky bottom breadcrumb on all height breakpoints 1`] = `
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -1400,7 +1400,7 @@ exports[`Page Verify sticky top breadcrumb on all height breakpoints - PageBread
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down Expand Up @@ -1545,7 +1545,7 @@ exports[`Page Verify sticky top breadcrumb on all height breakpoints 1`] = `
/>
<div
aria-hidden="false"
class="pf-v6-c-page__sidebar pf-m-expanded"
class="pf-v6-c-page__sidebar"
id="page-sidebar"
/>
<div
Expand Down
20 changes: 15 additions & 5 deletions packages/react-integration/cypress/integration/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ describe('Page Demo Test', () => {
it('Test Page elements', () => {
cy.get('#page-demo').within(() => {
cy.get('#nav-toggle').then((hamburgerIcon: JQuery<HTMLDivElement>) => {
cy.get('.pf-v6-c-page__sidebar.pf-m-expanded').should('exist');
cy.get('.pf-v6-c-page__sidebar.pf-m-collapsed').should('not.exist');
cy.wrap(hamburgerIcon).click();
cy.get('.pf-v6-c-page__sidebar.pf-m-collapsed').should('exist');
cy.get('.pf-v6-c-page__sidebar.pf-m-expanded').should('not.exist');
cy.get('#page-demo-sidebar').then(($sidebar) => {
const initiallyCollapsed = $sidebar.hasClass('pf-m-collapsed');
cy.wrap(hamburgerIcon).click();
if (initiallyCollapsed) {
cy.get('#page-demo-sidebar').should('not.have.class', 'pf-m-collapsed');
} else {
cy.get('#page-demo-sidebar').should('have.class', 'pf-m-collapsed');
}
cy.wrap(hamburgerIcon).click();
if (initiallyCollapsed) {
cy.get('#page-demo-sidebar').should('have.class', 'pf-m-collapsed');
} else {
cy.get('#page-demo-sidebar').should('not.have.class', 'pf-m-collapsed');
}
});
});
cy.get('#page-demo-masthead').should('not.have.attr', 'role');
cy.get('#page-demo-page-id').should('not.have.attr', 'role');
Expand Down
Loading