Skip to content

fix: place the Tooltip before the browser paints it - #33

Merged
inureyes merged 1 commit into
mainfrom
fix/tooltip-measure-before-paint
Sep 8, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/tooltip-measure-before-paint

Conversation

@inureyes

@inureyes inureyes commented Sep 8, 2026

Copy link
Copy Markdown
Member

Placement was measured in a frame scheduled after mount. Until that frame ran, the content sat in the DOM carrying visibility: hidden, which paints nowhere and, more to the point, takes it out of the accessibility tree: present, unreadable, and unfindable by any query that respects that tree.

It measures in a layout effect now. The content is in the DOM by the time that runs, and the state it sets is flushed before the browser paints, so the tooltip is never painted or exposed unplaced. The scroll and resize re-measurement moved into the same effect.

How it surfaced

A continuum-hub test that focuses a glossary term and looks for its tooltip failed once in a full-suite run and passed on its own and in the next full run. It was racing the frame: findByRole polls the accessibility tree, the tooltip is not in it until placement lands, and a loaded worker can miss a 1000ms window waiting for a frame that a starved jsdom is slow to schedule.

The package's own tests could not have caught this. Every one of them stubbed requestAnimationFrame to run synchronously, which is exactly the frame under suspicion. That was reasonable when I wrote them, since the alternative was making every assertion wait on frame timing, but it meant the suite was blind to the thing the stub replaced.

Tests

The stubs are gone, and all 31 tests run against real timing. One new test asserts the tooltip is in the accessibility tree in the same tick it opens, which is the assertion the stubs were standing in for.

Putting the frame back fails ten of them, including the new one.

pnpm run verify passes.

Refs lablup/continuum-hub#999

Placement was measured in a frame scheduled after mount. Until that frame ran, the content was in the DOM carrying `visibility: hidden`: painted nowhere, out of the accessibility tree, and unfindable by any query that respects the tree.

A layout effect measures it instead. The content is in the DOM by then, and the state it sets is flushed before paint, so the tooltip is never painted or exposed unplaced.

This surfaced as a flaky consumer test: focus a glossary term, look for the tooltip, and lose the race with the frame on a loaded machine. The package's own tests could not see it, because every one of them stubbed `requestAnimationFrame` to run synchronously. Those stubs are gone, and one test now asserts the tooltip is in the tree in the same tick it opens, which is the assertion the stubs were papering over: putting the frame back fails ten tests.
@inureyes
inureyes merged commit bdd9352 into main Sep 8, 2026
3 checks passed
@inureyes
inureyes deleted the fix/tooltip-measure-before-paint branch September 8, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant