Base UI Menu.Trigger's DOM node is re-created when the menu opens, so a mouse-up alone activates a menu item (React keeps the node)
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 45/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- react, typescript, vite
- Domínio
- developer-experience, frontend
Direção de pesquisa
Start by reproducing the issue with the provided Base UI menu example and compare the Redact and React builds. Trace how Redact handles the Menu.Trigger DOM node when opening the menu, then inspect the existing tests or add a focused regression case for node identity and mouse-up behavior. Done means the trigger node remains connected and unchanged across opening, and a mouse-up alone does not activate a menu item.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Opening a Base UI Menu replaces the trigger's host DOM node under Redact: after the mousedown that opens the menu, the <button> the page had before is detached (isConnected === false) and a new one is in its place. Under React 19 the node is kept.
Base UI relies on the node staying put. Menu.Trigger's onMouseDown starts a 200 ms timer that arms allowMouseUpTriggerRef ("release the mouse over an item → activate it") and registers a one-shot document mouseup listener that disarms it. When the mouseup lands on the detached node it never bubbles to document, the flag stays armed, and the next mouseup on any item activates it. Anything that dispatches events on an element reference (test harnesses, userEvent-style tooling) then sees an item activate twice: once from Base UI's synthesized click on mouseup, once from the real click. A real mouse is hit-tested onto the new node, so humans mostly don't notice, but the stale mousedown target also means the browser never fires click on the trigger itself.
In our app (TasksBoard, Base UI DropdownMenu on every task row) the production e2e run duplicated a task twice from one "Duplicate" click and lost a freshly created subtask editor; we reverted to React.
Reproduction
package.json
{
"name": "redact-menu-repro", "private": true, "type": "module",
"scripts": { "build": "vite build", "build:react": "REDACT=0 vite build --outDir dist-react" },
"dependencies": { "@base-ui/react": "1.8.0", "react": "19.2.0", "react-dom": "19.2.0" },
"devDependencies": { "@tanstack/redact": "0.2.1", "@vitejs/plugin-react": "4.3.4", "vite": "6.3.5" }
}
vite.config.js
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import { redact } from "@tanstack/redact/vite"
export default defineConfig({ plugins: [react(), ...(process.env.REDACT === "0" ? [] : [redact()])] })
index.html
<!doctype html><html><body><div id="root"></div><script type="module" src="/src/main.jsx"></script></body></html>
src/main.jsx
import React from "react"
import { createRoot } from "react-dom/client"
import { Menu } from "@base-ui/react/menu"
let clicks = 0
function App() {
return (
<Menu.Root>
<Menu.Trigger data-testid="trigger">Open</Menu.Trigger>
<Menu.Portal>
<Menu.Positioner>
<Menu.Popup>
<Menu.Item data-testid="item" onClick={() => { clicks++; document.getElementById("out").textContent = "item clicks: " + clicks }}>Item</Menu.Item>
</Menu.Popup>
</Menu.Positioner>
</Menu.Portal>
</Menu.Root>
)
}
createRoot(document.getElementById("root")).render(<><App /><p id="out">item clicks: 0</p></>)
pnpm install && pnpm build && pnpm build:react, serve dist/ (Redact) and dist-react/ (React), then run this in the console of each:
const sleep = ms => new Promise(r => setTimeout(r, ms))
const q = s => document.querySelector(`[data-testid="${s}"]`)
const ev = (e, type, buttons) => {
const r = e.getBoundingClientRect()
const at = { bubbles: true, cancelable: true, composed: true, view: window, button: 0, clientX: r.x + r.width / 2, clientY: r.y + r.height / 2 }
e.dispatchEvent(type.startsWith("pointer") ? new PointerEvent(type, { ...at, buttons, pointerId: 1, pointerType: "mouse", isPrimary: true }) : new MouseEvent(type, { ...at, buttons }))
}
const t = q("trigger")
ev(t, "pointerdown", 1); ev(t, "mousedown", 1); await sleep(50)
console.log({ menuOpen: !!q("item"), triggerSameNode: q("trigger") === t, heldTriggerConnected: t.isConnected })
ev(t, "pointerup", 0); ev(t, "mouseup", 0); await sleep(400)
const item = q("item")
ev(item, "pointerup", 0); ev(item, "mouseup", 0); await sleep(300) // a mouse-up alone, no click
console.log(document.getElementById("out").textContent)
Results
| build | after mousedown on the trigger |
after one mouseup on the item |
|---|---|---|
| React 19.2 | { menuOpen: true, triggerSameNode: true, heldTriggerConnected: true } |
item clicks: 0 |
| Redact 0.2.1 | { menuOpen: true, triggerSameNode: false, heldTriggerConnected: false } |
item clicks: 1 |
Expected: the trigger keeps its DOM node across the re-render that opens the menu (as React does), so Base UI's document mouseup sees the release and a lone mouseup on an item does nothing.
Versions: @tanstack/redact 0.2.1 (redact() with default options), @base-ui/react 1.8.0, react / react-dom 19.2.0, vite 6.3.5, Chrome 143 on macOS. Same with Base UI 1.8.0's useRenderElement-based Menu.Trigger in our app (DropdownMenu wrapper). Possibly related to #70 (Base UI submenu links close without navigating), which also involves a Base UI menu and real pointer input.
- Linguagem predominante
- TypeScript
- Estrelas
- 640
- Forks
- 32
- Merge médio
- 1h 15min
- PRs com merge (30d)
- 7
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/redact
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
TanStack/redact#195 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
TanStack/redact#142 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/redact
Issues semelhantes
-
bug data-types
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
ClickHouse/clickhouse-js#1293 ·
Mantenedores costumam responder em até 1 dia
-
area: middleware enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
agent/quality testing
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 95/100
Mantenedores costumam responder em até 1 dia
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
juspay/agent-distro#203 ·
Mantenedores costumam responder em até 1 dia