[FE] Close disabled-control tooltips with Escape

Abierto
#941 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@illiphilli ya está trabajando en esto.

Desde el 18/11/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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

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.

  1. In each control, add a useEffect that runs only while isTooltipOpen is true, adds a keydown listener on document, calls setShow(false) when event.key === 'Escape', and removes the listener on cleanup. Listening on document covers a tooltip opened by hover while focus is elsewhere.
  2. Don't move focus, call preventDefault, or stop propagation. The existing onToggle flow reopens the tooltip on the next hover or focus.
  3. 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).
  4. 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 toHaveAccessibleDescription still 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

Lenguaje dominante
Python
Estrellas
10
Forks
35
Merge medio
4 d 14 h
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openedx/openedx-core

Todos los issues de openedx/openedx-core

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.