Escape doesn't dismiss a ModalOverlay in WebKit while its CSS keyframe enter animation is running (react-aria 3.53 / RAC 1.22)

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
22/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, typescript
领域
frontend

调研方向

Start by reproducing the Escape-during-enter-animation case in Playwright WebKit using a ModalOverlay with a CSS keyframe animation while isEntering is true. Then trace how useEnterAnimation, useModalOverlay and useDialog gate keyboard dismissal on isEntering, using the 3.51.0 to 3.53.0 change (PR #10102) as the reference point. Done means Escape closes the modal during the enter animation in WebKit and the Chromium and Firefox behaviour is unchanged.

由索引模型根据 Issue 内容生成。

描述

waiting on author
Provide a general summary of the issue here

In WebKit, pressing Escape while a ModalOverlay is still playing a CSS keyframe enter animation does nothing, and the modal stays open. It works in Chromium and Firefox, and it worked in react-aria 3.51.0 / RAC 1.20.0. Using a CSS transition for the same fade instead of a keyframe animation avoids the problem.

🤔 Expected Behavior?

Escape dismisses the modal whenever it's open, including during its enter animation, as it did in 3.51.0 and still does in Chromium/Firefox.

😯 Current Behavior

The keypress is ignored until the enter animation has finished. Pressing Escape again afterwards closes the modal.

A minimal setup that reproduces it (Tailwind + tailwindcss-animate):

Open
<ModalOverlay
isDismissable
className={({ isEntering }) => isEntering ? 'animate-in fade-in duration-200' : ''}

<Modal>
  <Dialog><input autoFocus /></Dialog>
</Modal>
Playwright (WebKit): focus the trigger, press Enter, then press Escape right away. The dialog is still visible after 5 s.
StackBlitz Reproduction

It's hard to reproduce this in Stackblitz

🖥️ Steps to Reproduce
  1. Render the snippet above, with a CSS keyframe enter animation (e.g. animate-in fade-in duration-200) on ModalOverlay while isEntering.
  2. Open the page in Safari / Playwright WebKit.
  3. Focus the "Open" button and press Enter.
  4. Immediately press Escape, before the 200 ms fade-in has finished.
  5. The modal stays open. Pressing Escape again after the animation has finished closes it.
💁 Possible Solution

Keyboard dismissal (and the other useOverlay behaviour) should stay active while isEntering is true. Alternatively, the enter-animation tracking shouldn't block it when the running animation is a CSS keyframe animation on the overlay.

🔦 Context

Our Playwright WebKit integration tests started failing consistently after upgrading react-aria 3.51.0 → 3.53.1 and react-aria-components 1.20.0 → 1.22.1. It also affects real Safari users: Escape right after opening a modal (e.g. a ⌘K command menu) is ignored.

We worked around it by switching the overlay's fade from a CSS keyframe animation to a CSS transition, but keyframe enter animations on ModalOverlay are a common pattern (including in the RAC Tailwind examples), so others are likely to hit this.

PR #10102 (3.53.0) reworked useEnterAnimation and added isEntering handling to useModalOverlay/useDialog. That looks like the likely source; #10782 was another regression from the same change.

Version

[email protected]
[email protected]
[email protected]

What browsers are you seeing the problem on?

Safari

If other, please specify.

WebKit, Playwright WebKit 27.2

What operating system are you using?

macOS, and Linux

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

主要语言
TypeScript
星标
16k
派生
1.6k
平均合并
4 天 10 小时
30 天内合并 PR
42

环境准备

从这里开始

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

adobe/react-spectrum 的其他 Issue

查看 adobe/react-spectrum 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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