fix: Rendering race condition

This commit is contained in:
Sidharth Vinod
2025-03-14 15:40:14 -07:00
parent e394525376
commit 71a336c41f
+7 -1
View File
@@ -138,8 +138,14 @@
onMount(() => {
setupPanZoomObserver();
let pendingStateChange: Promise<void> | undefined;
stateStore.subscribe((state) => {
void handleStateChange(state);
// Queue state changes to prevent race condition
if (pendingStateChange) {
pendingStateChange = pendingStateChange.then(() => handleStateChange(state));
} else {
pendingStateChange = handleStateChange(state);
}
});
});
</script>