Page MenuHomePhabricator

Popover: handle keyboard navigation and clicks outside
Closed, ResolvedPublic2 Estimated Story Points

Description

Overview

Expected behavior

Keyboard navigation:

  • The Popover has a focusable reference element such as a toggle button or link.
  • To open the Popover, press Enter or Space on the focused toggle button. In the case of hover links, press Tab to focus on the link and show the Popover.
  • To close the Popover, press Escape or Tab to lose focus.
  • Tabbing inside a Popover should focus on its interactive elements. When you Tab from the last interactive element in the Popover, it will close the Popover and focus on the next interactive element that comes after the reference element (e.g. button).

Click event: When a Popover is open, clicks outside the Popover should close it.

Acceptance Criteria

  • Ensure the Enter and Space keys open and close the Popover.
  • Add a global escape key handler (refer to Tooltip). Make sure to add the event listener when the Popover is displayed and remove the event listener when the Popover is hidden.
  • Ensure the expected tab order when entering and exiting the focus of the Popover. This includes tabbing inside the Popover's interactive elements and tabbing to lose focus and close the Popover.
  • Ensure that clicking outside the Popover will close the Popover.

Event Timeline

@lwatson this isn't actually keyboard navigation, but I think we will also want to ensure that if you click outside of the popover, it closes. Should we update this task to include that? I thought it made sense to do it at the same time as the escape key handler since they behave the same way.

@AnneT - Yes, it makes sense to include handling the clicks outside the popover in this task.

lwatson renamed this task from Popover: handle keyboard navigation to Popover: handle keyboard navigation and clicks outside.Feb 24 2025, 3:56 PM
lwatson updated the task description. (Show Details)

Change #1122275 had a related patch set uploaded (by LWatson; author: LWatson):

[design/codex@main] Popover: handle keynav and clicks outside

https://gerrit.wikimedia.org/r/1122275

lwatson changed the task status from Open to In Progress.Feb 26 2025, 6:36 PM
lwatson updated the task description. (Show Details)

Change #1122275 merged by jenkins-bot:

[design/codex@main] Popover: handle keynav and clicks outside

https://gerrit.wikimedia.org/r/1122275

Change #1124526 had a related patch set uploaded (by LWatson; author: LWatson):

[mediawiki/core@master] Update Codex from v1.20.2 to v1.20.3

https://gerrit.wikimedia.org/r/1124526

Change #1124526 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.20.2 to v1.20.3

https://gerrit.wikimedia.org/r/1124526

Test wiki on Patch demo by LWatson-WMF using patch(es) linked to this task was deleted:

https://patchdemo.wmcloud.org/wikis/1f500859d0/w/