chore: fix preferences menu placement on mobile

This commit is contained in:
Aman Harwara
2023-05-04 15:41:57 +05:30
parent 85ad62389b
commit c9d8a686ff
2 changed files with 14 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import {
SelectItem, SelectItem,
SelectLabel, SelectLabel,
SelectPopover, SelectPopover,
SelectStoreProps,
useSelectStore, useSelectStore,
VisuallyHidden, VisuallyHidden,
} from '@ariakit/react' } from '@ariakit/react'
@@ -25,9 +26,19 @@ type DropdownProps = {
popover?: string popover?: string
} }
fullWidth?: boolean fullWidth?: boolean
popoverPlacement?: SelectStoreProps['placement']
} }
const Dropdown = ({ label, value, onChange, items, disabled, fullWidth, classNameOverride = {} }: DropdownProps) => { const Dropdown = ({
label,
value,
onChange,
items,
disabled,
fullWidth,
classNameOverride = {},
popoverPlacement,
}: DropdownProps) => {
const select = useSelectStore({ const select = useSelectStore({
defaultValue: value, defaultValue: value,
renderCallback(props) { renderCallback(props) {
@@ -37,6 +48,7 @@ const Dropdown = ({ label, value, onChange, items, disabled, fullWidth, classNam
popoverElement.style.zIndex = 'var(--z-index-dropdown-menu)' popoverElement.style.zIndex = 'var(--z-index-dropdown-menu)'
} }
}, },
placement: popoverPlacement,
}) })
const selectedValue = select.useState('value') const selectedValue = select.useState('value')

View File

@@ -58,6 +58,7 @@ const PreferencesMenuView: FunctionComponent<Props> = ({ menu }) => {
wrapper: 'relative', wrapper: 'relative',
button: 'focus:outline-none focus:shadow-none focus:ring-none', button: 'focus:outline-none focus:shadow-none focus:ring-none',
}} }}
popoverPlacement="top"
/> />
</div> </div>
</div> </div>