Fix hover transfer bugs occurring with the color picker popover (#4146)

* Fix hover transfer bugs occurring with the color picker popover

* Code review fix
This commit is contained in:
Keavon Chambers
2026-05-13 20:19:56 -07:00
committed by GitHub
parent 4d5dce976e
commit 696b625a3e
5 changed files with 25 additions and 23 deletions
+6 -3
View File
@@ -35,7 +35,8 @@ const { subscribe, update } = store;
export type ColorPickerStore = {
subscribe: typeof subscribe;
setCallbacks: (callbacks: ColorPickerCallbacks) => void;
clearCallbacks: () => void;
// Identity-checked so a hover-transfer race where another picker's `setCallbacks` already replaced these doesn't clobber the new picker's callbacks
clearCallbacks: (expected: ColorPickerCallbacks) => void;
setDragging: (dragging: boolean) => void;
};
@@ -88,10 +89,12 @@ export function createColorPickerStore(subscriptions: SubscriptionsRouter): Colo
return state;
});
},
clearCallbacks: () => {
clearCallbacks: (expected: ColorPickerCallbacks) => {
update((state) => {
state.callbacks = {};
state.isDragging = false;
if (state.callbacks === expected) {
state.callbacks = {};
}
return state;
});
},