Fixes to Dialog
Fix bad porting from useEffect--needs to run on destroy as well. Also fix a missing function invocation.
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
<script lang="ts" context="module">
|
||||
import { getContext, setContext, createEventDispatcher, tick } from "svelte";
|
||||
import {
|
||||
getContext,
|
||||
setContext,
|
||||
createEventDispatcher,
|
||||
tick,
|
||||
onDestroy,
|
||||
} from "svelte";
|
||||
export enum DialogStates {
|
||||
Open,
|
||||
Closed,
|
||||
@@ -97,6 +103,12 @@
|
||||
return useInertOthers(internalDialogRef, enabled);
|
||||
})();
|
||||
|
||||
onDestroy(() => {
|
||||
if (_cleanup) {
|
||||
_cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
let titleId: StateDefinition["titleId"] = null;
|
||||
|
||||
let api: Writable<StateDefinition | undefined> = writable();
|
||||
@@ -156,8 +168,13 @@
|
||||
document.documentElement.style.paddingRight = paddingRight;
|
||||
};
|
||||
})();
|
||||
onDestroy(() => {
|
||||
if (_cleanupScrollLock) {
|
||||
_cleanupScrollLock();
|
||||
}
|
||||
});
|
||||
|
||||
$: _cleanupClose = () => {
|
||||
$: _cleanupClose = (() => {
|
||||
if (_cleanupClose) {
|
||||
_cleanupClose();
|
||||
}
|
||||
@@ -181,7 +198,12 @@
|
||||
observer.observe(container);
|
||||
|
||||
return () => observer.disconnect();
|
||||
};
|
||||
})();
|
||||
onDestroy(() => {
|
||||
if (_cleanupClose) {
|
||||
_cleanupClose();
|
||||
}
|
||||
});
|
||||
|
||||
function handleClick(event: MouseEvent) {
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { getContext, setContext } from "svelte";
|
||||
import { getContext, onDestroy, setContext } from "svelte";
|
||||
import { writable, Writable } from "svelte/store";
|
||||
type OnUpdate = (message: StackMessage, element: HTMLElement | null) => void;
|
||||
|
||||
@@ -34,6 +34,12 @@
|
||||
$notifyStore(StackMessage.Add, element);
|
||||
return () => $notifyStore(StackMessage.Remove, element);
|
||||
})();
|
||||
|
||||
onDestroy(() => {
|
||||
if (_cleanup) {
|
||||
_cleanup();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
|
||||
Reference in New Issue
Block a user