fix: unwanted scrolling on notifications
Massimo Melina committed
Feb 22, 2026 at 10:51 UTC
23cc4ec968af75cd673ae464db10968fa1998cab
1 file changed
+5
-5
admin/src/dialog.ts
+5
-5
@@ -24,13 +24,13 @@ dialogsDefaults.Container = function Container(d: DialogOptions) {
24
const h = setTimeout(() => {
25
const el = ref.current
26
if (!el) return
27
- el.focus()
27
if (mobile) return
28
+ // Avoid forcing focus on passive dialogs: if nothing is focusable, we must not trigger page scrolling.
29
focusSelector('[autofocus]', el) || focusSelector(focusableSelector, el)
30
})
31
return () => clearTimeout(h)
32
- }, [ref.current])
33
- const titleSx = useDialogBarColors() // don't move this hook inside the return. When closing+showing at once it throws about rendering with fewer hooks.
32
+ }, [mobile, ref.current])
33
+ const titleSx = useDialogBarColors() // don't move this hook inside the return. When closing+showing at once, it throws about rendering with fewer hooks.
34
d = { ...dialogsDefaults, ...d }
35
const { sx, root, ...rest } = d.dialogProps||{}
36
if (d.noFrame)
@@ -149,7 +149,7 @@ export type FormDialog<T> = Omit<FormProps<T>, 'values' | 'save' | 'set'>
149
export async function formDialog<T>(
150
{ form, values, Wrapper, ...options }: Omit<DialogOptions, 'Content'> & {
151
values?: Partial<T>,
152
- form: FormDialog<T> | ((values: Partial<T>) => FormDialog<T>), // allow callback form
152
+ form: FormDialog<T> | ((values: Partial<T>) => FormDialog<T>), // allow a callback form
153
Wrapper?: FC
154
},
155
) : Promise<T> {
@@ -227,7 +227,7 @@ export function toast(msg: string | ReactElement, type: AlertType | ReactElement
227
fullScreen: false,
228
PaperProps: {
229
sx: { transition: `opacity ${ms}ms ease-in` },
230
- ref(x: HTMLElement) { // we need to set opacity later, to trigger transition
230
+ ref(x: HTMLElement) { // we need to set opacity later to trigger transition
231
if (x)
232
x.style.opacity = '0'
233
}