Skip to content

fix(popover): expose the popover as a dialog to assistive technology - #31824

Open
anasdahani220 wants to merge 4 commits into
ionic-team:mainfrom
anasdahani220:fix/popover-dialog-role
Open

anasdahani220 wants to merge 4 commits into
ionic-team:mainfrom
anasdahani220:fix/popover-dialog-role

Conversation

@anasdahani220

@anasdahani220 anasdahani220 commented Nov 25, 2026 •

Copy link
Copy Markdown

Issue number: resolves #31823


What is the current behavior?

ion-popover puts aria-modal="true" on its host but no role. aria-modal is only allowed on dialog and alertdialog, so axe reports aria-allowed-attr and screen readers don't announce the open popover as a dialog.

What is the new behavior?

  • role="dialog" and aria-modal="true" are now set on the popover content element inside the shadow root (part="content"), the same way ion-modal does it. The host no longer has aria-modal.
  • aria-label and role set on ion-popover or through htmlAttributes are moved to the content element, so apps can still override the role or add a name.
  • The content element has tabIndex={-1}, so present() moves focus to it. outline: none keeps it from showing a focus ring.
  • Updated popover-attributes.spec.tsx to check the content element, the inherited attributes, and that the host keeps neither role nor aria-modal.

Does this introduce a breaking change?

  • Yes
  • No

Other information

I ran the popover spec tests locally (all pass) and Prettier/ESLint on the changed files.

I used Claude to help me find the cause and write the test.

@anasdahani220
anasdahani220 requested a review from a team as a code owner November 25, 2026 10:34
@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

@anasdahani220 is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Nov 25, 2026

@thetaPC thetaPC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on your first contribution to Ionic Framework, and thanks for picking this up!

The fix is right that the popover needs a dialog role, but it has to sit on the content element the way ion-modal does it. Details are inline.

  • Please retitle to fix(popover): expose the popover as a dialog to assistive technology, since the role no longer goes on the host, and update "What is the new behavior?" to match.
  • Please also check arrow-key navigation in a dropdown popover, nested popovers, and ion-select with interface="popover", since focus now lands on the content element when the popover opens.

Comment thread core/src/components/popover/popover.tsx Resolved
@anasdahani220 anasdahani220 changed the title fix(popover): add dialog role to the popover host fix(popover): expose the popover as a dialog to assistive technology Nov 26, 2026
@anasdahani220

Copy link
Copy Markdown
Author

Thanks for the detailed review! I moved role and aria-modal to the content element and inherited aria-label/role like ion-modal does, then updated the tests, the title and the description. I checked keyboard navigation (↑/↓, Esc) in a dropdown popover, nested popovers, and ion-select with interface="popover", and focus lands on the content without a focus ring.

@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 26, 2026 3:13am UTC

Request Review

@thetaPC thetaPC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing before CI can pass: should not override keyboard interactions for textarea elements in popover.e2e.ts now fails in Firefox. With focus on the popover content, Firefox's first Tab stops on the scrollable ion-textarea before its inner textarea, the same as it does from a focused native <dialog> or ion-modal. The test covers arrow, Home and End keys, so it can focus the textarea directly instead of tabbing to it:

await expect(popover).toBeFocused();

/**
 * Focus the textarea directly instead of tabbing to it. In Firefox,
 * Tab from the focused popover content stops on the scrollable
 * ion-textarea first, the same as it does for a native dialog.
 */
await innerNativeTextarea.focus();

await expect(innerNativeTextarea).toBeFocused();

@anasdahani220

Copy link
Copy Markdown
Author

Thanks, that makes sense. I updated the test to focus the textarea directly, with your comment explaining the Firefox behavior.

This branch was successfully deployed

1 active (outdated) deployment
Preview — 9dcd132f Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-popover has aria-modal but no dialog role

2 participants