`@effect/ui-kit` (Effect-TS/ui): `Dialog` / `Drawer` cannot dismiss via `backdrop` click or `<dialog>` `cancel` when `runsMounts: false`

Đang mở
#11,059 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@effect-bot đang làm issue này rồi.

Từ ngày 29/11/2026.

  • #626 của @effect-bot — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

What version of Effect is running?
  • effect: 4.1.6
  • @effect/ui & @effect/ui-kit: Effect-TS/ui main at 77391ee50ae3d3175d670facbf675e9a819ba6a6
What steps can reproduce the bug?
  1. Clone the minimal reproduction branch:
    git clone -b repros/non-dom-host-uikit-bugs https://github.com/cliffordfajardo/ui.git effect-ui-repro
    cd effect-ui-repro
    pnpm install
    pnpm repro:test
    
  2. Render an open Dialog (or Drawer) on TestHost (which sets runsMounts: false, matching any non-DOM host that disables browser-DOM mounts) and either:
    • click dialog.backdrop, or
    • fire the native <dialog> cancel event on dialog.portal.

Minimal repro (see 02-dialog-drawer-no-backdrop-or-cancel-without-mounts/repro.test.ts):

const play = yield* HtmlPlay.make(DialogApp, {})
assert.strictEqual(play.root.model()?.open, true)

// 1. Click dialog.backdrop
yield* play.click(Locator.attr("class", "backdrop"))
assert.strictEqual(play.root.model()?.open, false)

// 2. Dispatch native cancel on <dialog>
yield* play.fire(Locator.tag("dialog"), "cancel", {})
assert.strictEqual(play.root.model()?.open, false)
What is the expected behavior?

When disablePointerDismissal is not true, clicking dialog.backdrop should emit RequestedClose (e.g. with reason "outside-press"), and dispatching cancel on the <dialog> portal should emit RequestedClose (e.g. with reason "escape-key"), even when runsMounts: false (such as in HtmlPlay on TestHost or on a non-DOM Html host).

What do you see instead?

Neither backdropPart (packages/ui-kit/src/Dialog.ts:1408-1419) nor portalPart (packages/ui-kit/src/Dialog.ts:1349-1397) attaches a declarative event handler — both outside-press dismissal and close-watcher/escape dismissal live exclusively inside the browser-DOM TrackDialog mount.

In HtmlPlay on TestHost:

Error: HtmlPlay.click: nothing handles "click" at [class="backdrop"]

and:

Error: HtmlPlay.fire: nothing handles "cancel" at <dialog>
Additional information

Encountered while running @effect/ui-kit's Dialog and Drawer on a non-DOM Html host (ns-effect-ui's MasonHost) with runsMounts: false, where the only working dismissal path without patching or wrapping backdrop was clicking an explicit dialog.close(...) button.

Adding declarative .on("click", ...) on backdropPart (respecting disablePointerDismissal and deduplicating with TrackDialog when mounts run) and .on("cancel", ...) on portalPart would make Dialog and Drawer dismissal work consistently in HtmlPlay/TestHost tests as well as on non-DOM Html hosts.

Ngôn ngữ chính
TypeScript
Star
16.7k
Fork
808
Merge trung bình
21 giờ 22 phút
Pull request đã merge (30 ngày)
486

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Effect-TS/effect

Tất cả issue của Effect-TS/effect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.