#797 adjust height of timezone selector when openning on mobile
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
List,
|
List,
|
||||||
InputAdornment,
|
InputAdornment,
|
||||||
useTheme
|
styled
|
||||||
} from '@linagora/twake-mui'
|
} from '@linagora/twake-mui'
|
||||||
import { Search as SearchIcon } from '@mui/icons-material'
|
import { Search as SearchIcon } from '@mui/icons-material'
|
||||||
import React, { useState, useMemo, useEffect, useRef } from 'react'
|
import React, { useState, useMemo, useEffect, useRef } from 'react'
|
||||||
@@ -14,6 +14,10 @@ import { TimezoneSelectProps } from './TimezoneSelector'
|
|||||||
import { useI18n } from 'twake-i18n'
|
import { useI18n } from 'twake-i18n'
|
||||||
import { TimezoneListItem } from './TimezoneListItem'
|
import { TimezoneListItem } from './TimezoneListItem'
|
||||||
|
|
||||||
|
const StyledSwipeableDrawer = styled(SwipeableDrawer)(({ theme }) => ({
|
||||||
|
zIndex: theme.zIndex.modal + 100
|
||||||
|
}))
|
||||||
|
|
||||||
const filterTimezones = (
|
const filterTimezones = (
|
||||||
zones: string[],
|
zones: string[],
|
||||||
query: string,
|
query: string,
|
||||||
@@ -35,8 +39,6 @@ export const SmallTimezoneSelector: React.FC<
|
|||||||
> = ({ value, onChange, referenceDate, onClose, open }) => {
|
> = ({ value, onChange, referenceDate, onClose, open }) => {
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const theme = useTheme()
|
|
||||||
|
|
||||||
const [searchQuery, setSearchQuery] = useState('')
|
const [searchQuery, setSearchQuery] = useState('')
|
||||||
const timezoneList = useTimeZoneList()
|
const timezoneList = useTimeZoneList()
|
||||||
|
|
||||||
@@ -84,7 +86,7 @@ export const SmallTimezoneSelector: React.FC<
|
|||||||
window.innerHeight - viewport.offsetTop - viewport.height
|
window.innerHeight - viewport.offsetTop - viewport.height
|
||||||
)
|
)
|
||||||
paper.style.bottom = `${bottom}px`
|
paper.style.bottom = `${bottom}px`
|
||||||
paper.style.height = `${viewport.height}px`
|
paper.style.height = `${viewport.height - 70}px`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewport) {
|
if (viewport) {
|
||||||
@@ -94,7 +96,7 @@ export const SmallTimezoneSelector: React.FC<
|
|||||||
}
|
}
|
||||||
|
|
||||||
inputRef.current?.focus()
|
inputRef.current?.focus()
|
||||||
selectedRef.current?.scrollIntoView({ behavior: 'auto', block: 'center' })
|
selectedRef.current?.scrollIntoView({ behavior: 'auto', block: 'start' })
|
||||||
|
|
||||||
return (): void => {
|
return (): void => {
|
||||||
if (viewport) {
|
if (viewport) {
|
||||||
@@ -109,7 +111,7 @@ export const SmallTimezoneSelector: React.FC<
|
|||||||
}, [open])
|
}, [open])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SwipeableDrawer
|
<StyledSwipeableDrawer
|
||||||
anchor="bottom"
|
anchor="bottom"
|
||||||
open={open}
|
open={open}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
@@ -121,7 +123,6 @@ export const SmallTimezoneSelector: React.FC<
|
|||||||
sx: { height: '90%', maxHeight: '90dvh' }
|
sx: { height: '90%', maxHeight: '90dvh' }
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
sx={{ zIndex: theme.zIndex.modal + 100 }}
|
|
||||||
>
|
>
|
||||||
<Box sx={{ px: 2 }}>
|
<Box sx={{ px: 2 }}>
|
||||||
<TextField
|
<TextField
|
||||||
@@ -169,6 +170,6 @@ export const SmallTimezoneSelector: React.FC<
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
</SwipeableDrawer>
|
</StyledSwipeableDrawer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user