diff --git a/app/scenes/Document/components/Combobox.tsx b/app/scenes/Document/components/Combobox.tsx index ebaa008a97..8d2ca0c0a4 100644 --- a/app/scenes/Document/components/Combobox.tsx +++ b/app/scenes/Document/components/Combobox.tsx @@ -10,11 +10,12 @@ import { import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import { s, ellipsis } from "@shared/styles"; -import { Background, Placement } from "~/components/ContextMenu"; +import { Backdrop, Background, Placement } from "~/components/ContextMenu"; import { MenuAnchorCSS } from "~/components/ContextMenu/MenuItem"; import { LabelText, Outline, Wrapper } from "~/components/Input"; import { Positioner } from "~/components/InputSelect"; import { Portal } from "~/components/Portal"; +import useMobile from "~/hooks/useMobile"; import { undraggableOnDesktop } from "~/styles"; type Suggestion = { @@ -53,7 +54,9 @@ function Combobox({ }: Props) { const [focused, setFocused] = React.useState(false); const [items, setItems] = React.useState(suggestions); - const [listWidth, setListWidth] = React.useState(0); + const [listWidth, setListWidth] = React.useState(0); + + const isMobile = useMobile(); const handleBlur = () => { setFocused(false); @@ -73,11 +76,11 @@ function Combobox({ }); React.useEffect(() => { - if (state.visible && state.unstable_disclosureRef.current) { + if (!isMobile && state.visible && state.unstable_disclosureRef.current) { const elem = state.unstable_disclosureRef.current; setListWidth(elem.clientWidth); } - }, [state.visible, state.unstable_disclosureRef]); + }, [state.visible, state.unstable_disclosureRef, isMobile]); React.useEffect(() => { state.setValues(suggestions.map((s) => s.value)); @@ -115,7 +118,9 @@ function Combobox({ {...state} aria-label={listLabel} modal - style={{ width: `${listWidth}px` }} + style={{ + width: isMobile ? "auto" : `${listWidth}px`, + }} > {( props: React.HTMLAttributes & { @@ -130,33 +135,40 @@ function Combobox({ } return ( - - - - {state.visible - ? items.map((item) => ( - { - onSelectOption(item); - state.setInputValue(""); - state.hide(); - }} - > - {item.label ?? item.value} - - )) - : null} - - - + <> + {state.visible && isMobile && ( + + + + )} + + + + {state.visible + ? items.map((item) => ( + { + onSelectOption(item); + state.setInputValue(""); + state.hide(); + }} + > + {item.label ?? item.value} + + )) + : null} + + + + ); }}