fix: forms in dialogs were autofocusing on tablets

Massimo Melina committed Oct 23, 2024 at 17:27 UTC c56ce2b9d31f480d57741664fbd2fb45996c4ad9
1 file changed +2 -4
admin/src/dialog.ts
+2 -4
@@ -8,11 +8,10 @@ import {
8 } from 'react'
9 import { Check, Close, Error as ErrorIcon, Forward, Info, Warning } from '@mui/icons-material'
10 import { newDialog, closeDialog, dialogsDefaults, DialogOptions, componentOrNode, pendingPromise,
11 - focusSelector, md, focusableSelector } from '@hfs/shared'
11 + focusSelector, md, focusableSelector, useIsMobile } from '@hfs/shared'
12 import { Form, FormProps } from '@hfs/mui-grid-form'
13 import { IconBtn, Flex, Center } from './mui'
14 import { useDark } from './theme'
15 -import { useWindowSize } from 'usehooks-ts'
15 import _ from 'lodash'
16 import { err2msg } from './misc'
17 import { useSnapState } from './state'
@@ -20,8 +19,7 @@ export * from '@hfs/shared/dialogs'
19
20 dialogsDefaults.Container = function Container(d: DialogOptions) {
21 const ref = useRef<HTMLElement>()
23 - const { width, height } = useWindowSize()
24 - const mobile = width > 0 && Math.min(width, height) < 500
22 + const mobile = useIsMobile()
23 useEffect(()=> {
24 const h = setTimeout(() => {
25 const el = ref.current