mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-09-23 19:06:33 +00:00
fix(share): stop ShareDialog effect from wedging the scheduler in prod (#686)
ShareDialog tracked the open transition with `let prevOpen = $state(false)` and an `$effect.pre` that both read and wrote `prevOpen` — a self-invalidating effect. In dev this trips `effect_update_depth_exceeded`; in a production build the guard differs and it silently wedges Svelte's global effect scheduler the moment `open` flips on close. Result: after opening+closing the share dialog, effects stop flushing app-wide — clicks change the URL but the view never re-renders (no error, no CPU spin). Make `prevOpen` a plain variable (it's only used for edge-detection inside the effect), so the effect depends solely on `open` and never re-triggers itself.
This commit is contained in:
@@ -33,8 +33,12 @@
|
||||
let newlyCreatedLinkId = $state<string | null>(null);
|
||||
let deletingLinkId = $state<string | null>(null);
|
||||
|
||||
// Track previous open state to detect open transitions
|
||||
let prevOpen = $state(false);
|
||||
// Track previous open state to detect open transitions. This is a PLAIN
|
||||
// variable (not $state) on purpose: it's only read/written inside the
|
||||
// effect below for edge-detection. Making it $state turned the effect
|
||||
// into a self-invalidating loop (it writes a state it reads), which in a
|
||||
// production build silently wedges Svelte's effect scheduler on close.
|
||||
let prevOpen = false;
|
||||
|
||||
$effect.pre(() => {
|
||||
if (open && !prevOpen) {
|
||||
|
||||
Reference in New Issue
Block a user