Skip to content

Commit

Permalink
Merge pull request #16285 from schlawg/ui-has-dialog-touch-scroll
Browse files Browse the repository at this point in the history
disable body scroll on touch devices with css
  • Loading branch information
ornicar authored Oct 29, 2024
2 parents 953f1b6 + 07eaa70 commit b1d72fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ui/common/css/component/_dialog.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
body:has(dialog.touch-scroll) {
overflow: hidden !important;
}

dialog {
@extend %box-radius, %popup-shadow;
position: fixed;
Expand Down
6 changes: 1 addition & 5 deletions ui/common/src/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function alert(msg: string): Promise<void> {
await domDialog({
htmlText: escapeHtml(msg),
class: 'alert',
show: 'modal',
show: true,
});
}

Expand Down Expand Up @@ -226,7 +226,6 @@ export function snabDialog(o: SnabDialogOpts): VNode {
}

class DialogWrapper implements Dialog {
private restore?: { focus?: HTMLElement; overflow: string };
private resolve?: (dialog: Dialog) => void;
private actionEvents = eventJanitor();
private dialogEvents = eventJanitor();
Expand Down Expand Up @@ -339,9 +338,6 @@ class DialogWrapper implements Dialog {
private onRemove = () => {
this.observer.disconnect();
if (!this.dialog.returnValue) this.dialog.returnValue = 'cancel';
this.restore?.focus?.focus(); // one modal at a time please
if (this.restore?.overflow !== undefined) document.body.style.overflow = this.restore.overflow;
this.restore = undefined;
this.resolve?.(this);
this.o.onClose?.(this);
this.dialog.remove();
Expand Down

0 comments on commit b1d72fc

Please sign in to comment.