Skip to content

fix(PageSidebar): keep collapsed content out of the tab order - #12720

Open
Sophran-fbj wants to merge 1 commit into
patternfly:mainfrom
Sophran-fbj:fix/page-sidebar-collapsed-focus
Open

Sophran-fbj wants to merge 1 commit into
patternfly:mainfrom
Sophran-fbj:fix/page-sidebar-collapsed-focus

Conversation

@Sophran-fbj

@Sophran-fbj Sophran-fbj commented Nov 16, 2026 •

Copy link
Copy Markdown

What: Closes #12693

A collapsed PageSidebar is hidden from assistive technology, but keyboard users could still tab into links and controls rendered inside it. Set native inert on the collapsed sidebar using PatternFly's existing React compatibility helper. Expanding the sidebar restores keyboard access. The context-selector demo now relies on the sidebar for this behavior.

The Cypress regression uses a native Tab keypress at 390 px. On upstream main, focus went to the collapsed sidebar link. With the fix, it moves to the main-content link and can reach the sidebar link again after expansion.

Validation

  • yarn test:integration --browser <electron|chrome> --spec 'cypress/integration/page.spec.ts,cypress/integration/pagemanagedsidebarclosed.spec.ts' — 5 passed in each browser.
  • yarn exec jest --runInBand --testPathPattern 'components/(Page|Nav)/__tests__' — 171 passed across 17 suites.
  • yarn lint:all, yarn build:esm, yarn build:cjs, yarn build:subpaths, yarn build:single:packages, and yarn build:integration passed. I used the published @patternfly/react-tokens@6.7.0 artifacts for the local Windows build after interrupting slow token generation.

Additional issues: PatternFly Page design documentation.

Assisted-by: OpenAI Codex

Summary by CodeRabbit

  • Accessibility
    • When the page sidebar is collapsed, its interactive content is removed from the tab order and hidden from assistive technology. Keyboard navigation proceeds to the main content instead.
    • When the sidebar is open, its links are available to keyboard and assistive technology users.
  • Documentation
    • Updated the context selector guidance to reflect the sidebar’s behavior when collapsed.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

PageSidebar now applies inert when closed. The managed-sidebar demo and Cypress test cover accessibility state and keyboard focus order before and after the sidebar opens.

Changes

Collapsed sidebar focus handling

Layer / File(s) Summary
Apply inert to the closed sidebar
packages/react-core/src/components/Page/PageSidebar.tsx, packages/react-core/src/demos/examples/Page/PageContextSelector.tsx, packages/react-core/src/demos/Page.md
The sidebar receives inert when closed. The context selector no longer sets a conditional tabIndex. Documentation describes how a collapsed sidebar affects the tab order.
Verify sidebar focus order
packages/react-integration/demo-app-ts/src/components/demos/PageDemo/PageManagedSidebarClosedDemo.tsx, packages/react-integration/cypress/integration/pagemanagedsidebarclosed.spec.ts
The demo provides links for focus-order checks. The Cypress test checks the sidebar accessibility state and keyboard focus before and after opening the sidebar.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: tlabaj, thatblindgeye

Merge Risk: Minimal · up to 7eefd

A collapsed page sidebar is now removed from the keyboard tab order and restored when it is opened. The change is small, reversible, and covered by a new keyboard regression test, so no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the component (PageSidebar) and the change: collapsed sidebar content is removed from the tab order. The raw summary confirms the main change is applying native inert to the collapsed …
Linked Issues check Passed Issue #12693 requires that a collapsed, aria-hidden PageSidebar also leave the focus order. The issue lists inert on the sidebar as one acceptable approach. At the reviewed head, PageSidebar.tsx app…
Out of Scope Changes check Passed All changed files relate to the fix or its verification. PageSidebar.tsx adds the inert attribute, which is the requested change. PageContextSelector.tsx removes the sidebar-dependent tabIndex, which …
Full details: Title check

Explanation

The title names the component (PageSidebar) and the change: collapsed sidebar content is removed from the tab order. The raw summary confirms the main change is applying native inert to the collapsed PageSidebar, with supporting doc, demo, and Cypress test updates. The title is specific and matches the linked issue's request to remove collapsed content from focus order.

Full details: Linked Issues check

Explanation

Issue #12693 requires that a collapsed, aria-hidden PageSidebar also leave the focus order. The issue lists inert on the sidebar as one acceptable approach. At the reviewed head, PageSidebar.tsx applies {...(!sidebarOpen &amp;&amp; { inert: IS_INERT })} on the same element that sets aria-hidden={!sidebarOpen}. When the sidebar is open, inert is not applied, so keyboard access is restored. IS_INERT is defined in packages/react-core/src/helpers/inert.ts. It returns true for React 19 and later, and '' for earlier versions, so the attribute renders correctly on both. The added Cypress spec pagemanagedsidebarclosed.spec.ts checks at 390x792 that Tab moves past the collapsed sidebar to the main-content link, and that a sidebar link is reachable after expansion. Coding requirements are met. Unit-test coverage for the inert attribute itself was not confirmed in the reviewed evidence; the Cypress spec covers the behavior. Pull request objectives mention #12720, but that reference is not part of the current linked issue set and was not used as a requirement.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the fix or its verification. PageSidebar.tsx adds the inert attribute, which is the requested change. PageContextSelector.tsx removes the sidebar-dependent tabIndex, which is no longer needed because the sidebar now handles focus removal through inert. Page.md updates the context-selector guidance to match that behavior. pagemanagedsidebarclosed.spec.ts adds the regression test. PageManagedSidebarClosedDemo.tsx adds the main-content link and page-section link that the test uses for Tab-order checks. These are supporting test and documentation changes. No unrelated changes were found in the summary. Source blobs for the diff could not be read through the diff operation, so the assessment relies on the file read and the supplied summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b943a9e3-b984-4f8f-9962-d23e92f0937c
Commits

Reviewing files that changed from the base of the PR and between 75b6b80 and 7eefda4.

Files selected for processing: 5

  • packages/react-core/src/components/Page/PageSidebar.tsx
  • packages/react-core/src/demos/Page.md
  • packages/react-core/src/demos/examples/Page/PageContextSelector.tsx
  • packages/react-integration/cypress/integration/pagemanagedsidebarclosed.spec.ts
  • packages/react-integration/demo-app-ts/src/components/demos/PageDemo/PageManagedSidebarClosedDemo.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - PageSidebar - collapsed sidebar is aria-hidden but its navigation links stay in the tab order

1 participant