BitPdfViewer hands the focus back for the wrong dialog when two viewers' dialogs close out of order

未关闭
#15,622 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@msynk 已经在做这个了。

开始于 2026年12月5日。

评估

这个 Issue 还没有评估数据。

描述

BitPdfViewerE2ETests.Encrypted_APromptTheReaderDidNotOpen_LeavesTheFocusOfAnotherControlAlone (src/BlazorUI/Tests/E2E/Bit.BlazorUI.Tests.E2E/Extras/BitPdfViewerE2ETests.cs) failed on both tries in "blazorui e2e / E2E webkit / wasm / 1 of 4" of All Other E2E CI run 47434192777, while the other 2005 tests passed. It fails on the test's last line, after the password dialog of #pdv-encrypted-late has closed:

Locator expected to be focused
  - Expect "ToBeFocusedAsync" Locator("#btn-load-encrypted-late") with timeout 30000ms
    63 × locator resolved to <button id="btn-load-encrypted-late">Load encrypted</button>
       - unexpected value "inactive"

Cause: BitPdfViewer. trapFocus (BitPdfViewer.ts) pushes the control a dialog should hand the focus back to onto PdfViewer._focusReturn, and releaseFocus pops the last entry. That stack is shared by every viewer on the page, so when two viewers have a dialog open at once and the earlier one is still open, closing the later one releases the earlier one's entry. The test page has two such dialogs: #pdv-encrypted asks for its password as the page loads, and #pdv-encrypted-late asks once the test presses its button. The test doesn't wait for the first one. When it arrives after the second one is trapped, closing the second pops the first one's entry (focus left where it was, never entered), and the focus stays on <body>.

Probe run 47456869305 (WebKit, WebAssembly, trapFocus and releaseFocus logged with the stack):

  • As the test runs, 10 of 10 passed. In 2 of them #pdv-encrypted's dialog wasn't on the page yet when the button was pressed, and was trapped only after that.
  • With #pdv-encrypted's trap held until #pdv-encrypted-late's, 4 of 4 failed the way CI did. The release popped #pdv-encrypted's entry, left #pdv-encrypted-late's on the stack, and the focus stayed on <body>.
  • With the test waiting for #pdv-encrypted's dialog first, 4 of 4 passed.

The test passed on WebKit/WebAssembly in the 12-01 and 12-02 nights. Tonight's run lost that race on both tries.

Fix. Each entry records its viewer and its dialog. releaseFocus takes the viewer's root and releases that viewer's dialog that has left the DOM, wherever it sits in the stack, and drops the entries of viewers no longer on the page. A new test, Encrypted_TwoPromptsClosedOutOfOrder_EachHandsTheFocusBackToItsOwnOpener, answers #pdv-encrypted's prompt while #pdv-encrypted-late's is still open, then expects the second one's closing to hand the focus back to its button.

主要语言
C#
星标
1.4k
派生
264
平均合并
5 小时 25 分钟
30 天内合并 PR
447

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bitfoundation/bitplatform 的其他 Issue

查看 bitfoundation/bitplatform 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。