bug: ion-modal sheets presented back to back overflow the call stack
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript, web-dev
- Lĩnh vực
- accessibility, frontend
Hướng nghiên cứu
Read core/src/components/modal/modal.tsx, especially onModalFocus around lines 1225-1236, and the overlay focus trap in core/src/utils/overlays.ts. Reproduce the stack overflow by presenting two sheet modals back to back, then check how the topmost overlay is identified. Done when the lower modal no longer moves focus to its drag handle and the reproduction no longer overflows the call stack.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v9.x, Nightly
Current Behavior
When a second sheet modal is presented before the first sheet's present() has resolved, the page throws RangeError: Maximum call stack size exceeded and the UI stops responding.
The loop runs like this:
- When the first modal's enter animation ends, it focuses its wrapper. The second modal is already the topmost overlay.
- The overlay focus trap (
trapShadowFocusincore/src/utils/overlays.ts, a capture listener ondocument) sees focus outside the topmost overlay. The second modal has no element that matchesfocusableQueryString, so the trap focuses the second modal's host synchronously. - The first modal's
onModalFocus(core/src/components/modal/modal.tsx, lines 1225-1236 onmain) sees its host focused with no focused element in its shadow root, and callsdragHandleEl.focus()(line 1234). In v9 every sheet has a focusable handle, becausehandleBehaviordefaults tocycle. - The trap moves focus back to the second modal, and steps 3 and 4 repeat until the call stack overflows.
If the second modal contains a radio group, the trap focuses it through the async setFocus(), and the loop does not start. The guard added in #31293 (shadowRoot.activeElement == null) does not stop this case, because the host itself is focused and nothing inside it is.
Stack (Chromium, 9.0.10, unminified build):
RangeError: Maximum call stack size exceeded.
at focusVisibleElement (helpers.js:165:6)
at focusElementInContext (overlays.js:124:7)
at focusFirstDescendant (overlays.js:106:3)
at trapShadowFocus (overlays.js:239:7)
at trapKeyboardFocus (overlays.js:247:5)
at HTMLDocument.<anonymous> (overlays.js:256:7)
Results from the reproduction, 20 headless Playwright runs per cell:
@ionic/core |
Chromium | WebKit |
|---|---|---|
| 9.0.10 | 20 of 20 | 18 of 20 |
| 9.0.11 | 20 of 20 | 19 of 20 |
| 9.0.12-nightly.20261116 | 20 of 20 | 20 of 20 |
Expected Behavior
Presenting a second sheet before the first sheet has finished presenting does not loop. A modal that is not the topmost overlay does not move focus to its own drag handle while the focus trap moves focus into the overlay above it.
Steps to Reproduce
- Clone the reproduction, then run
npm installandnpx vite. - Open the page and the browser console.
- Tap Present both. It calls
first.present()without awaiting it, then callssecond.present(). - The console shows
RangeError: Maximum call stack size exceeded.
Code Reproduction URL
https://github.com/srobroek/ionic-sheet-focus-repro
Ionic Info
The reproduction uses @ionic/core only, with no framework, built with Vite 7.
Ionic CLI : 7.2.1
@ionic/core : 9.0.10 (also tested 9.0.11 and 9.0.12-nightly.20261116)
NodeJS : v24.22.0
npm : 11.19.1
OS : Linux 6.12
Browsers : Playwright 1.65.0 Chromium and WebKit, headless
Additional Information
Possible fix: in onModalFocus, call dragHandleEl.focus() only when this modal is the topmost presented overlay, for example when getPresentedOverlay(document, 'ion-modal') === this.el (core/src/utils/overlays.ts, line 481).
Workaround: a capture-phase focus listener on document.documentElement that calls stopPropagation() when the event target is an ion-modal that is not document.activeElement. The reproduction includes it behind ?guard=1, and with it the error occurred in 0 of 20 runs on each version in Chromium.
Related: #24491 is an older focus trap recursion with stacked overlays, fixed in #24611. #31293 added the host-focus guard in onModalFocus.
This issue and the reproduction were prepared with the help of an AI assistant. I verified that the reproduction triggers the error and that the workaround removes it.
- Ngôn ngữ chính
- TypeScript
- Star
- 52.8k
- Fork
- 13.3k
- Merge trung bình
- 3 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 78
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ionic-team/ionic-framework
-
bug: input-otp, backspace in an empty box only moves focus instead of clearing the previous boxCó thể đã có người làm @sarankumar1325 đã nhận 24 ngày trước. Đang mởpackage: core type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
ionic-team/ionic-framework#31639 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: vue swipe cancellation throws when the previous page is missingCó thể đã có người làm @dandoingdev đã nhận 47 ngày trước. Đang mởpackage: vue type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ionic-team/ionic-framework#31514 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: ion-searchbar input is always labelled "search text"; aria-label on the host is not forwardedCó thể đã có người làm @HappyKnuckles đã nhận 41 ngày trước. Đang mởa11y package: core type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
ionic-team/ionic-framework#31492 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: IonTabs throws when a Fragment contains one IonRouterOutletCó thể đã có người làm @Benziza đã nhận 82 ngày trước. Đang mởpackage: react type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ionic-team/ionic-framework#31410 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: angular swipe-back gesture crashes in StackController.startBackTransition when the stack is popped before the gesture is capturedCó thể đã có người làm @officialasishkumar đã nhận 10 ngày trước. Đang mởpackage: angular type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
ionic-team/ionic-framework#31291 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ionic-team/ionic-framework
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vercel-labs/ui#809 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bot:ai-assisted component:platform-js status:untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
midnightntwrk/platform-js#38 ·
-
[bug] Second false positive on high-cost plugin alert: detection only compares patch entry id, community plugin dsh-auto | [bug] 高成本插件告警第二次误报:检测只比对 patch 条目 id,社区插件 dsh-auto-review 被认成 @deepseek-ai/dsh-experimental-auto-reviewCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ranxianglei/billion-context#7068 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
vendor: bump whisper.cpp past 6a8addd — the current pin aborts the app on a failed Metal initĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mybigday/whisper.rn#348 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
six-group/six-webcomponents#600 ·