Skip to content

fix(popover) Close popover on Esc when focus is outside content - #17439

Open
999purple999 wants to merge 1 commit into
jitsi:masterfrom
999purple999:fix/popover-esc-after-hover
Open

fix(popover) Close popover on Esc when focus is outside content#17439
999purple999 wants to merge 1 commit into
jitsi:masterfrom
999purple999:fix/popover-esc-after-hover

Conversation

@999purple999

Copy link
Copy Markdown

Summary

The Popover component declares an Esc-key handler (_onEscKey) but attaches it only to the inner .popover-content div. That div renders inside a DialogPortal, so for hover-triggered popovers — and for any case where focus remains on the trigger after the popover opens — the Esc keydown event never reaches the content handler and the popover cannot be closed by keyboard.

The fix attaches the same handler to the outer container so Esc bubbles up from the trigger (or anywhere inside the container) and closes the popover. The internal guard is tightened so preventDefault / stopPropagation only runs when the popover is actually visible — avoiding any chance of swallowing Esc for unrelated handlers when the popover is closed.

Closes

Related (out of scope, but same cluster)

The same accessibility audit also reported four issues that need separate fixes in other components (SettingsDialog, ParticipantsPane, focus-into-menu on open). I'm happy to follow up with separate PRs if this one is acceptable.

Test plan

  • tsc --noEmit -p tsconfig.web.json — clean
  • eslint react/features/base/popover/components/Popover.web.tsx — clean
  • Manual on meet.jit.si build: hover reactions button → press Esc → menu closes (and triggering element retains focus, matching audit recommendation "closable without moving focus").
  • Manual: tab to reactions button, Space to open via keyboard → Esc still closes (regression check).
  • Manual: click three-dot menu (overflow) → Esc → menu closes.
  • Manual: press Esc while no popover is open → other Esc handlers (e.g. dialog close) still fire as before.

Disclosure

This patch was drafted with AI assistance and reviewed by me before submission.

The Popover component already had an Esc handler, but it was attached
only to the .popover-content div (which renders into a portal). For
hover-triggered popovers (reactions menu, etc.) and for any case where
focus remains on the trigger after opening, the Esc keydown never
reaches the content div, so the popover cannot be closed by keyboard.

Move the Esc handler to the outer container so it fires whether focus
is on the trigger element or inside the popover content. Tighten the
guard so the preventDefault/stopPropagation only runs when the popover
is actually visible, to avoid swallowing Esc for unrelated handlers.

Fixes jitsi#17374 (reactions menu Esc-after-hover)
Fixes jitsi#17373 (three-dot menu Esc-after-hover)
@jitsi-jenkins

Copy link
Copy Markdown

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Accessibility] ESC doesn't close the reactions menu after hover [Accessibility] ESC doesn't close the three-dot menu after hover

2 participants