Open dnnsmnstrr opened 1 year ago
I am also experiencing this in the same circumstance of a conditionally rendered dialog and currently working around it by adding the document.body.classList.remove("mdc-dialog-scroll-lock")
to the on:click
handlers for all of the action buttons.
I tried adding it to the on:SMUIDialog:closing
and on:SMUIDialog:closed
handlers but that didn't seem to work. I'm guessing that the reactivity logic in Dialog.svelte:199-211
is happening after the dialog close events, but not really sure.
Describe the bug I am using the Dialog component within a child component of a SvelteKit page, which renders the component dependent on a condition (the dialog asks to confirm the cancellation of a file upload). When the cancellation is confirmed, the component containing the dialog closes, changing the condition and therefore not being rendered anymore. Unfortunately, following this action, scrolling on the page is disabled.
I was able to pinpoint the problem to the
mdc-dialog-scroll-lock
class not being removed from the document body, which could be solved by callingdocument.body.classList.remove('mdc-dialog-scroll-lock')
in the on:click of the Dialog-Action-Button. Maybe there is a way to fix this in the component itself?To Reproduce The scenario is recreated in this REPL
Show Dialog Button
to enable the condition that renders the dialog componentOpen Dialog
and confirm by clickingyes
To test the fix, uncomment line 24 in
Dialog.svelte
and repeat the previous stepsExpected behavior After clicking on a button within the Dialog, page-scrolling is not locked when the dialog is closed.
Desktop: