ActionMenu.Anchor should only accept button
Los mantenedores suelen responder en 1 día
@siddharthkp ya está trabajando en esto.
Desde el 9/3/2026.
- #7640 de @copilot-swe-agent — cerrado sin fusionar
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Description
ActionMenu has preferred API of ActionMenu.Button which uses a Primer Button and wires it up correctly.
However, if you want to customise the anchor, we also provide a ActionMenu.Anchor that can be used to give a custom element.
While this API is required, it's possible to use it incorrectly.
Spotted in the wild: In this example, the developer is trying to add an "active indicator" on the IconButton by adding an additional element (with aria-label) and positioning it
<ActionMenu.Anchor>
<div className="relative">
<IconButton aria-label="Filter files in tree" icon={FilterIcon} />
{filterEnabled && (
<div aria-label="Showing only files changed" className="active-indicator" />
)}
</div>
</ActionMenu.Anchor>
The above JSX renders inaccessible html:
<div
class="relative"
id=":rku:" <!-- used to label the menu when open, this should have been on the button? -->
aria-haspopup="true"
aria-expanded="false"
tabindex="0" <!-- tabindex=0 added by ActionMenu to make sure anchor gets focus -->
>
<button
data-component="IconButton"
type="button"
aria-labelledby=":rl0:" <!-- points to tooltip -->
aria-describedby=":rl1:-loading-announcement"
>
<svg aria-hidden="true"></svg>
</button>
<span
class="Tooltip__StyledTooltip-sc-e45c7z-0 iBBTma"
id=":rl0:"
aria-hidden="true"
popover="auto"
>
Filter files in tree
</span>
<div aria-label="Showing only changed files" class="absolute active-indicator"/>
</div>
https://github.com/user-attachments/assets/988470d7-0f1a-43a8-aa7b-3a874dc3cb33
Video description:
- Pressing tab on the close button seems to focus the filter button but does not show tooltip.
- The screen reader reads out "Filter files in tree, Showing only changed files, menu pop-up, group"
- You'd expect tabbing again would focus the text input, but it focuses the button instead. Now a tooltip is visible with text "Filter files in tree".
- The screen reader now reads "Filter files in tree, button, Filter files in tree, Showing only changed files, menu pop-up, group" (still reading out the group)
- Tabbing again finally focuses the text input
Proposed Solution
I have 2 suggestions:
- Reduce: The most common use case of
ActionMenu.Anchoris to use anIconButton, we should create a shortcutActionMenu.IconButtonas a companion toActionMenu.Button.
A blessed shortcut would reduce the chances of implementing it incorrectly. - Validate:
ActionMenu.Anchorshould validate it's children, if it receives an incorrect element as the root, it should throw a warning and guide the developer to correct usage.
My guess is that only button is valid, but we need to validate that assumption. Non-interactive element is definitely a violation. For prior art, we have similar (if not more advanced) checks in Tooltip
Suggested prioritisation:
I have fixed the instance where this was spotted so I am not blocked.
But there are 258 instances of ActionMenu.Anchor that need to be audited for their children to decide if this is a widespread bug or a good to have
Steps to reproduce
Navigate to custom anchor story and replace the Anchor with:
<ActionMenu.Anchor>
<div className="relative">
<IconButton aria-label="Filter files in tree" icon={FilterIcon} />
{filterEnabled && (
<div aria-label="Showing only files changed" className="active-indicator" />
)}
</div>
</ActionMenu.Anchor>
Version
v37.5.0
Browser
Chrome
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.9k
- Forks
- 691
- Merge medio
- 3 d 6 h
- PR fusionados (30 d)
- 54
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de primer/react
-
ActionMenu: add preventFocusOnClosePosiblemente ocupada @tay1orjones la tomó hace 2 días. Abiertocomponent: ActionMenu
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
primer/react#8488 · 1 comentario · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
FormControl renders duplicate non-choice inputs when layout="horizontal"Posiblemente ocupada @namangoyal176-10 la tomó hace 2 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
PageHeader.Title does not seem to accept id propPosiblemente ocupada @minwookshin la tomó hace 8 días. Abiertocomponent: PageHeader react staff
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
primer/react#8474 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
The padding prop seems to have no effect with PageLayout.SidebarPosiblemente ocupada @minwookshin la tomó hace 8 días. Abiertocomponent: PageLayout react staff
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
primer/react#8470 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
bug component: Spinner react
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
primer/react#8423 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de primer/react
Issues similares
-
Add: YRF Music NepalAbiertostreams:add
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
walletbeat/walletbeat#1558 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
hawk-digital-environments/HAWKI#438 ·
Los mantenedores suelen responder en 1 día
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
GiganticMinecraft/seichi-portal-frontend#1165 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día