Graph root is not a containing block for absolutely positioned layers
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #425 di @draedful — integrata
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- playwright, react, typescript
Direzione di ricerca
Start with packages/graph/src/services/Layer.css, Graph.attach(root), and packages/graph-react/src/graph-canvas.css to trace how the root and layers are positioned. Then inspect the contract apps and the linked pull request #425; the acceptance criteria call for a vanilla graph E2E test with a padded, bordered root, unchanged React behavior, and an intentional decision about the contract workarounds and migration docs.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Core layers are absolutely positioned (packages/graph/src/services/Layer.css: .layer { position: absolute; inset: 0; width: 100%; height: 100% }), but neither Graph.attach(root) nor the core stylesheet makes the root a containing block, and the docs do not say the root must be positioned. Only the React wrapper does it (packages/graph-react/src/graph-canvas.css: position: relative).
In a vanilla app whose root is not positioned, the layers are laid out against the nearest positioned ancestor or the viewport, not against the root:
- the canvas covers the page (observed
0,0 1280×720for a root at24,24 902×652); - pointer hit-testing uses canvas-relative coordinates (
Graph.getPointInCameraSpace→getXY(canvas, event)), while the camera's wheel zoom (Camera.ts) and code that maps world points to the root (cameraService.getAbsoluteXY+ root rect, used by@gravity-ui/graph-playwright) use the root's box. Clicks land ~25px off. Large blocks absorb the error; thin connections are missed.
The package-contract apps work around it with style="position: relative" on #graph (packages/graph-devtools/contract/app/index.html, packages/graph-playwright/contract/app/index.html); the shared scripts/package-contract/shared/base.css does not set it.
Proposal
Pick one and document it:
- Core makes the root a containing block, e.g. a
.graph-root { position: relative }class added byattach()(and removed on detach), or an inline style only when the computedpositionisstatic. Consumers' own positioning keeps working. - Or document the requirement in the core README / getting-started docs and warn in development when the attached root has
position: static.
Option 1 is preferred: it matches what GraphCanvas already does and removes a silent misalignment.
Acceptance criteria
- A vanilla graph attached to a non-positioned root renders inside the root and hit-tests correctly (E2E: root with padding/border, click a connection via
GraphConnectionPO.click()). - React
GraphCanvasbehaviour is unchanged. - The
position: relativeworkarounds in contract apps are removed or kept intentionally; docs and the v1→v2 migration guide mention the change if behaviour changes.
Found while adding the graph-playwright package contract in #406.
🤖 Drafted with Claude Code
- Lingua principale
- TypeScript
- Stelle
- 145
- Fork
- 12
- Merge medio
- 1g 14h
- PR unite (30g)
- 43
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di gravity-ui/graph
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
gravity-ui/graph#457 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
gravity-ui/graph#455 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
gravity-ui/graph#456 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
gravity-ui/graph#431 ·
I maintainer di solito rispondono entro 1 giorno
-
proposal
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
gravity-ui/graph#416 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di gravity-ui/graph
Issue simili
-
area:cli area:security bug priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
rtk-ai/rtk#5127 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
"code source" and "numerique.gouv" links: "new window" mention duplicated in the accessible nameApertaaccessibility
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
numerique-gouv/lasuite-landingpage#315 ·
I maintainer di solito rispondono entro 1 giorno
-
needs:triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
HyeokjaeChoi/vaultme#585 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement priority/P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
beettlle/pi-smart-router#200 ·