Repository navigation
fix(core): position widgets relative to their canvas - #10491
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e82274bc6e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const canvasBounds = canvas?.getBoundingClientRect(); | ||
| const parentBounds = this.parentElement?.getBoundingClientRect(); | ||
| return { | ||
| x: canvasBounds && parentBounds ? canvasBounds.left - parentBounds.left : 0, | ||
| y: canvasBounds && parentBounds ? canvasBounds.top - parentBounds.top : 0, |
There was a problem hiding this comment.
Measure from the actual positioned widget origin
In the React integration, parentElement is the unpositioned .deck-widgets-root rendered after the heightful .deck-events-root, while the absolutely positioned widget containers use the positioned wrapper as their containing block. Subtracting the widget root's rectangle therefore commonly produces a canvas y offset of roughly minus the Deck height, moving every tooltip and view-scoped widget offscreen. Resolve bounds against the containers' actual containing block, or make the widget root itself cover and position the shared widget area.
Useful? React with 👍 / 👎.
Goal
Position existing Deck widgets and tooltips correctly when their rendering canvas is offset from the shared widget root.
Changes
viewId, and placement documentation and TSDoc.Scope
Seven widget implementation, documentation, and test files only. No
DeckAPI changes, multi-canvas props, presentation contexts, event-manager lifecycle changes, or example applications.Validation
./node_modules/.bin/tsc -p modules/core/tsconfig.json --noEmit --pretty falseyarn test-headless test/modules/core/lib/widget-manager.spec.ts test/modules/core/lib/tooltip.spec.ts test/modules/core/lib/deck.spec.ts --retry 1 --silent— 39 tests passed.Stack