From 97627cd7cd77e98137372b6cdf22b3f54c95979a Mon Sep 17 00:00:00 2001 From: anasdahani220 Date: Wed, 25 Nov 2026 10:30:00 +0000 Subject: [PATCH 1/4] fix(popover): add dialog role to the popover host --- core/src/components/popover/popover.tsx | 1 + .../popover/test/popover-attributes.spec.tsx | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 core/src/components/popover/test/popover-attributes.spec.tsx diff --git a/core/src/components/popover/popover.tsx b/core/src/components/popover/popover.tsx index 68006141a33..ea5af1906f7 100644 --- a/core/src/components/popover/popover.tsx +++ b/core/src/components/popover/popover.tsx @@ -773,6 +773,7 @@ export class Popover implements ComponentInterface, PopoverInterface { return ( { + it('should have role="dialog" alongside aria-modal', async () => { + const page = await newSpecPage({ + components: [Popover], + template: () => , + }); + + const popover = page.body.querySelector('ion-popover')!; + expect(popover.getAttribute('role')).toBe('dialog'); + expect(popover.getAttribute('aria-modal')).toBe('true'); + }); + + it('should allow the role to be overridden via htmlAttributes', async () => { + const page = await newSpecPage({ + components: [Popover], + template: () => , + }); + + const popover = page.body.querySelector('ion-popover')!; + expect(popover.getAttribute('role')).toBe('alertdialog'); + }); +}); From 2f0c8d111958a3802c9038c2ab57bc8604a6797e Mon Sep 17 00:00:00 2001 From: anasdahani220 Date: Thu, 26 Nov 2026 01:09:14 +0000 Subject: [PATCH 2/4] fix(popover): expose the popover as a dialog to assistive technology --- core/src/components/popover/popover.scss | 1 + core/src/components/popover/popover.tsx | 36 +++++++++++++++--- .../popover/test/popover-attributes.spec.tsx | 37 ++++++++++++++++--- 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/core/src/components/popover/popover.scss b/core/src/components/popover/popover.scss index 1fd11ddf896..9ec9c692e9c 100644 --- a/core/src/components/popover/popover.scss +++ b/core/src/components/popover/popover.scss @@ -81,6 +81,7 @@ .popover-content { display: flex; + outline: none; position: absolute; flex-direction: column; diff --git a/core/src/components/popover/popover.tsx b/core/src/components/popover/popover.tsx index ea5af1906f7..21dc28021eb 100644 --- a/core/src/components/popover/popover.tsx +++ b/core/src/components/popover/popover.tsx @@ -2,7 +2,7 @@ import type { ComponentInterface, EventEmitter } from '@stencil/core'; import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core'; import { focusFirstDescendant } from '@utils/focus-trap'; import { CoreDelegate, attachComponent, detachComponent } from '@utils/framework-delegate'; -import { addEventListener, raf, hasLazyBuild } from '@utils/helpers'; +import { addEventListener, raf, hasLazyBuild , inheritAttributes } from '@utils/helpers'; import { createLockController } from '@utils/lock-controller'; import { printIonWarning } from '@utils/logging'; import { OverlayFocusBoundary } from '@utils/overlay-focus-boundary'; @@ -30,6 +30,7 @@ import { iosEnterAnimation } from './animations/ios.enter'; import { iosLeaveAnimation } from './animations/ios.leave'; import { mdEnterAnimation } from './animations/md.enter'; import { mdLeaveAnimation } from './animations/md.leave'; +import type { Attributes } from '@utils/helpers'; import type { PopoverInterface, PopoverSize, @@ -71,6 +72,7 @@ export class Popover implements ComponentInterface, PopoverInterface { private headerResizeObserver?: ResizeObserver; private inline = false; + private inheritedAttributes: Attributes = {}; private workingDelegate?: FrameworkDelegate; private focusDescendantOnPresent = false; @@ -389,7 +391,21 @@ export class Popover implements ComponentInterface, PopoverInterface { } componentWillLoad() { - const { el } = this; + const { el, htmlAttributes } = this; + + const attributesToInherit = ['aria-label', 'role']; + this.inheritedAttributes = inheritAttributes(el, attributesToInherit); + if (htmlAttributes !== undefined) { + attributesToInherit.forEach((attribute) => { + if (htmlAttributes[attribute]) { + this.inheritedAttributes = { + ...this.inheritedAttributes, + [attribute]: htmlAttributes[attribute], + }; + delete htmlAttributes[attribute]; + } + }); + } const popoverId = this.htmlAttributes?.id ?? setOverlayId(el); this.parentPopover = el.closest(`ion-popover:not(#${popoverId})`) as HTMLIonPopoverElement | null; @@ -772,8 +788,6 @@ export class Popover implements ComponentInterface, PopoverInterface { return ( this.dismiss() : undefined}> {enableArrow &&
} -
+
diff --git a/core/src/components/popover/test/popover-attributes.spec.tsx b/core/src/components/popover/test/popover-attributes.spec.tsx index 786d7bb0bc8..6fed4966c9c 100644 --- a/core/src/components/popover/test/popover-attributes.spec.tsx +++ b/core/src/components/popover/test/popover-attributes.spec.tsx @@ -3,25 +3,50 @@ import { newSpecPage } from '@stencil/core/testing'; import { Popover } from '../popover'; +// Fixes https://github.com/ionic-team/ionic-framework/issues/31823 describe('popover: attributes', () => { - it('should have role="dialog" alongside aria-modal', async () => { + it('should set the dialog role and aria-modal on the content', async () => { const page = await newSpecPage({ components: [Popover], template: () => , }); const popover = page.body.querySelector('ion-popover')!; - expect(popover.getAttribute('role')).toBe('dialog'); - expect(popover.getAttribute('aria-modal')).toBe('true'); + const content = popover.shadowRoot!.querySelector('[part="content"]')!; + + expect(content.getAttribute('role')).toBe('dialog'); + expect(content.getAttribute('aria-modal')).toBe('true'); + expect(popover.hasAttribute('aria-modal')).toBe(false); }); - it('should allow the role to be overridden via htmlAttributes', async () => { + it('should inherit attributes', async () => { const page = await newSpecPage({ components: [Popover], - template: () => , + template: () => , }); const popover = page.body.querySelector('ion-popover')!; - expect(popover.getAttribute('role')).toBe('alertdialog'); + const content = popover.shadowRoot!.querySelector('[part="content"]')!; + + expect(content.getAttribute('aria-label')).toBe('my label'); + expect(content.getAttribute('role')).toBe('alertdialog'); + }); + + it('should inherit attributes when set via htmlAttributes', async () => { + const page = await newSpecPage({ + components: [Popover], + template: () => ( + + ), + }); + + const popover = page.body.querySelector('ion-popover')!; + const content = popover.shadowRoot!.querySelector('[part="content"]')!; + + expect(content.getAttribute('aria-label')).toBe('my label'); + expect(content.getAttribute('role')).toBe('alertdialog'); + + expect(popover.hasAttribute('aria-label')).toBe(false); + expect(popover.hasAttribute('role')).toBe(false); }); }); From 9dcd132f5a362fb67b6e8c43ff82a95ad6df06d1 Mon Sep 17 00:00:00 2001 From: anasdahani220 Date: Thu, 26 Nov 2026 01:55:14 +0000 Subject: [PATCH 3/4] chore(popover): fix lint --- core/src/components/popover/popover.scss | 3 ++- core/src/components/popover/popover.tsx | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/components/popover/popover.scss b/core/src/components/popover/popover.scss index 9ec9c692e9c..c61cdec8d71 100644 --- a/core/src/components/popover/popover.scss +++ b/core/src/components/popover/popover.scss @@ -81,7 +81,6 @@ .popover-content { display: flex; - outline: none; position: absolute; flex-direction: column; @@ -94,6 +93,8 @@ min-height: var(--min-height); max-height: var(--max-height); + outline: none; + background: var(--background); box-shadow: var(--box-shadow); diff --git a/core/src/components/popover/popover.tsx b/core/src/components/popover/popover.tsx index 21dc28021eb..70195e38c88 100644 --- a/core/src/components/popover/popover.tsx +++ b/core/src/components/popover/popover.tsx @@ -2,7 +2,8 @@ import type { ComponentInterface, EventEmitter } from '@stencil/core'; import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core'; import { focusFirstDescendant } from '@utils/focus-trap'; import { CoreDelegate, attachComponent, detachComponent } from '@utils/framework-delegate'; -import { addEventListener, raf, hasLazyBuild , inheritAttributes } from '@utils/helpers'; +import { addEventListener, raf, hasLazyBuild, inheritAttributes } from '@utils/helpers'; +import type { Attributes } from '@utils/helpers'; import { createLockController } from '@utils/lock-controller'; import { printIonWarning } from '@utils/logging'; import { OverlayFocusBoundary } from '@utils/overlay-focus-boundary'; @@ -30,7 +31,6 @@ import { iosEnterAnimation } from './animations/ios.enter'; import { iosLeaveAnimation } from './animations/ios.leave'; import { mdEnterAnimation } from './animations/md.enter'; import { mdLeaveAnimation } from './animations/md.leave'; -import type { Attributes } from '@utils/helpers'; import type { PopoverInterface, PopoverSize, From 3f211543615c55282022ee5b857e081155968895 Mon Sep 17 00:00:00 2001 From: anasdahani220 Date: Thu, 26 Nov 2026 10:15:10 +0000 Subject: [PATCH 4/4] test(popover): focus the textarea directly in the keyboard test --- core/src/components/popover/test/basic/popover.e2e.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/components/popover/test/basic/popover.e2e.ts b/core/src/components/popover/test/basic/popover.e2e.ts index 44f0ee7dd06..d9832b9697c 100644 --- a/core/src/components/popover/test/basic/popover.e2e.ts +++ b/core/src/components/popover/test/basic/popover.e2e.ts @@ -220,7 +220,12 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => */ await expect(popover).toBeFocused(); - await page.keyboard.press(tabKey); + /** + * 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();