fix: avoid scrolling of the page while a dialog is open
Massimo Melina committed
Jul 27, 2023 at 13:27 UTC
467fd674722912da27595773fd390c795ec168b3
1 file changed
+3
shared/dialogs.ts
+3
@@ -30,6 +30,9 @@ export const dialogsDefaults: Partial<DialogOptions> = {
30
31
export function Dialogs() {
32
const snap = useSnapshot(dialogs)
33
+ useEffect(() => {
34
+ document.body.style.overflow = snap.length ? 'hidden' : ''
35
+ }, [snap.length])
36
return h(Fragment, {},
37
snap.length > 0 && snap.map(d =>
38
h(Dialog, { key: d.$id, ...(d as DialogOptions) })))