Skip to content

Commit 1530b99

Browse files
committed
fix(themer): report the theme cross-fade so switching does not linger
The machine leaves its `switching` state when the layout reports a view transition under way, or after `MOTION_DURATION` when nothing does. Nothing reported it any more, so the tag lasted the full 2s fallback and in-place color edits to the applied theme in that window started a theme cross-fade instead of tracking the pointer.
1 parent 3d55c40 commit 1530b99

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎plugins/@sanity/themer/src/tool/ThemerLayout.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,17 @@ export function ThemerLayout({
153153
startTransition(() => {
154154
if(switching) {
155155
addThemerTransitionType('crossfade')
156+
// The cross-fade is under way, so the machine is no longer switching —
157+
// the in-place color edits that may follow track the pointer instead
158+
send({type: 'layout.transitioned'})
156159
}
157160
if (activeOptions === null) {
158161
dispatch({type: 'unset-theme'})
159162
} else {
160163
dispatch({type: 'set-theme', theme: activeOptions})
161164
}
162165
})
163-
}, [activeOptions, dispatch, switching])
166+
}, [activeOptions, dispatch, send, switching])
164167

165168
// The Studio paints the body with its configured theme from above this
166169
// layout, and Safari tints its chrome from the body — so the applied theme

0 commit comments

Comments
 (0)