Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix: mobile drawer glitches

flooorianflo7b93c65d092d
diff --git a/packages/ui/src/input-select.tsx b/packages/ui/src/input-select.tsx
index 39a072d66b..2146baa002 100644
--- a/packages/ui/src/input-select.tsx
+++ b/packages/ui/src/input-select.tsx
@@ -73,6 +73,14 @@ export function InputSelect({
const { isMobile } = useMediaQuery();
+ // isFocused is used to determine if the input is focused to fix mobile issues with keyboard + drawer
+ const [isFocused, setIsFocused] = useState(false);
+ useEffect(() => {
+ if (!openCommandList) {
+ setIsFocused(false);
+ }
+ }, [openCommandList]);
+
const CommandInput = () => {
const isEmpty = useCommandState((state: any) => state.filtered.count === 0);
return (
@@ -80,10 +88,13 @@ export function InputSelect({
<Command.Input
placeholder={inputAttrs?.placeholder || "Search..."}
// hack to focus on the input when the dropdown opens
- autoFocus={openCommandList}
+ autoFocus={(openCommandList && !isMobile) || (isMobile && isFocused)}
onFocus={() => setOpenCommandList(true)}
value={inputValue}
- onValueChange={setInputValue}
+ onValueChange={(value) => {
+ setInputValue(value);
+ setIsFocused(true);
+ }}
onKeyDown={(e) => {
if (e.key === "Escape") {
e.preventDefault();