[FE] Close disabled-control tooltips with Escape
维护者通常 1 天内回复
@illiphilli 已经在做这个了。
开始于 2026年11月18日。
评估
这个 Issue 还没有评估数据。
描述
User Story
As a course author who uses a keyboard or a screen magnifier, I want to close a disabled control's tooltip with Escape, in order to clear it off the page without moving away from the control.
Description
On the Competency Management page, the "+ Rule" and "+ Rule Group" controls and the blocked associate pill tell you why they're disabled with a tooltip that opens on hover or keyboard focus. Right now the only way to close that tooltip is to move the mouse or the focus somewhere else, which falls short of WCAG 2.1 1.4.13 (Content on Hover or Focus). Pressing Escape should close it and leave focus where it is, on both controls, so they keep behaving the same way.
Context
- The blocked associate pill comes from https://github.com/openedx/frontend-app-authoring/pull/3376 (https://github.com/openedx/openedx-core/issues/797), so that half lands once the PR merges.
- Found in the AI review of that PR. The pill reuses the tooltip pattern from
AddControl, so both have the same gap. - Making the tooltip hoverable (the other half of 1.4.13) is out of scope here. It needs its own design call.
UX Design
No visual change. This ticket only adds keyboard behavior to the existing tooltips.
Acceptance Criteria
Scenario: Escape closes the tooltip on a focused disabled control
Given a disabled "+ Rule" control with keyboard focus and its tooltip open
When I press Escape
Then the tooltip closes
And keyboard focus stays on the control
And a screen reader still describes the control with the reason it is disabled
Scenario: Escape closes a tooltip that opened on hover
Given a disabled "+ Rule Group" control whose tooltip opened because the pointer is over it
And keyboard focus is somewhere else on the page
When I press Escape
Then the tooltip closes
And the tooltip stays closed while the pointer stays over the control
Scenario: The tooltip opens again on the next hover or focus
Given I closed a disabled control's tooltip with Escape
When I move the pointer off the control and back on, or move focus off and back on
Then the tooltip opens again
Scenario: Escape closes the tooltip on a blocked associate pill
Given a subsection in a blocked course, with its associate pill focused and the conflict tooltip open
When I press Escape
Then the tooltip closes
And keyboard focus stays on the pill
And a screen reader still describes the pill with the conflict message
Scenario: Activating a disabled control keeps its reason on screen
Given a disabled control with keyboard focus and its tooltip open
When I press Enter or Space
Then nothing is added or associated
And the tooltip stays open
Scenario: Escape on an enabled control does nothing
Given an enabled "+ Rule" control with keyboard focus
When I press Escape
Then no tooltip appears
And keyboard focus stays on the control
Technical Details
This is a suggested approach, not the source of truth. The User Story, Description, and Acceptance Criteria define what must be true when the work is done.
Approach
Both controls hold the tooltip's open state in const [show, setShow] = useState(false), derive isTooltipOpen = disabled && show, pass show={isTooltipOpen} and onToggle={setShow} to Paragon's OverlayTrigger, and switch aria-describedby between the tooltip id and a static sr-only description id on isTooltipOpen. Closing the tooltip only needs setShow(false); the description switch follows from it.
- In each control, add a
useEffectthat runs only whileisTooltipOpenis true, adds akeydownlistener ondocument, callssetShow(false)whenevent.key === 'Escape', and removes the listener on cleanup. Listening ondocumentcovers a tooltip opened by hover while focus is elsewhere. - Don't move focus, call
preventDefault, or stop propagation. The existingonToggleflow reopens the tooltip on the next hover or focus. - Repeat the effect in both controls rather than sharing a hook: there are two callers, and they sit in sibling feature folders (
criteria-groups,course-search). - Edge cases the tests cover in each control: Escape with hover only (focus elsewhere), and Enter or Space leaving the tooltip open. After Escape, focus is unchanged and
toHaveAccessibleDescriptionstill returns the reason.
Files to create and modify
| File | Change |
|---|---|
| src/taxonomy/competency-management/criteria-groups/AddControl.tsx | modified: Escape effect |
| src/taxonomy/competency-management/criteria-groups/AddControl.test.tsx | modified: Escape tests |
| src/taxonomy/competency-management/course-search/CourseOutlineSubtree.tsx | modified: Escape effect in AddSubsectionPill |
| src/taxonomy/competency-management/course-search/CourseOutlineSubtree.test.tsx | modified: Escape tests for the blocked pill |
Additional context
- 主要语言
- Python
- 星标
- 10
- 派生
- 35
- 平均合并
- 4 天 14 小时
- 30 天内合并 PR
- 20
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openedx/openedx-core 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
openedx/openedx-core#942 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
openedx/openedx-core#934 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
openedx/openedx-core#922 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
openedx/openedx-core#831 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
openedx/openedx-core#827 ·
维护者通常 1 天内回复
查看 openedx/openedx-core 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
mozilla-ai/cq#601 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
intcomma returns exponential notation for large floats可能已有人在做 @Omarinho12345 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
python-humanize/humanize#521 ·
维护者通常 1 天内回复
-
LUCJ pass manager raises NoEdgeBetweenNodes when an edge is bad for two two-qubit gates可能已有人在做 @hat-im 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
opensubtitlescom: provider rejects pt-PT even though its own converter maps it可能已有人在做 @paulo-0308 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
Diaoul/subliminal#1405 ·