Skip to content

Commit abf1bde

Browse files
Waleed Latifwaleedlatif1
authored andcommitted
fix(desktop): arm the peek before first paint
Review round 2: the title-bar seed ran in a passive effect, which lands after paint — long enough for a `mouseenter` on the toggle to be dropped while the peek still read disabled, with nothing to retry it until the pointer left and returned. A regression from folding the seed into the window-state effect during cleanup. Promoted to a layout effect, which runs before paint and before any mouse event can be dispatched. The body is cheap synchronous reads plus a subscription; the bridge's getState stays async and blocks nothing.
1 parent 3ec18bc commit abf1bde

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

apps/sim/app/workspace/[workspaceId]/components/workspace-chrome/workspace-chrome.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,16 @@ export function WorkspaceChrome({
195195
})
196196
}, [])
197197

198-
useEffect(() => {
199-
// Seed from the attribute the pre-paint script already wrote, so the peek is armed
200-
// on the first hover instead of waiting for the async bridge below to resolve.
198+
/**
199+
* A layout effect, not a passive one: the seed below arms the peek, and a passive
200+
* effect lands after paint — long enough for a `mouseenter` on the toggle to be
201+
* dropped while the peek still reads disabled, with nothing to retry it until the
202+
* pointer leaves and returns. Everything here is a cheap synchronous read plus a
203+
* subscription; the bridge's `getState` stays async and blocks nothing.
204+
*/
205+
useLayoutEffect(() => {
206+
// Seed from the attribute the pre-paint script already wrote, rather than waiting
207+
// for the async bridge below to resolve.
201208
const initial = document.documentElement.getAttribute('data-sim-desktop-title-bar')
202209
if (initial === 'inset' || initial === 'fullscreen') setTitleBarMode(initial)
203210

0 commit comments

Comments
 (0)