Skip to content

Commit bec98ac

Browse files
authored
Merge pull request #644 from code16/fix-mobile-date
Fix date not opening in android
2 parents 64b2ad1 + 5aa1d12 commit bec98ac

File tree

1 file changed

+11
-3
lines changed
  • resources/js/form/components/fields

1 file changed

+11
-3
lines changed

resources/js/form/components/fields/Date.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { createYear, createYearRange, toDate } from 'reka-ui/date'
3434
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
3535
import { Button } from "@/components/ui/button";
3636
import { __ } from "@/utils/i18n";
37+
import { PopoverAnchor } from "reka-ui";
3738
import { getDefaultDateLocale, getWeekStartsOn } from "@/utils/dates";
3839
3940
const props = defineProps<FormFieldProps<FormDateFieldData>>();
@@ -159,13 +160,20 @@ function onMinuteChange(minute: string) {
159160
);
160161
}
161162
}
163+
164+
function onInputClick(e: MouseEvent) {
165+
if(!isTouch.value) {
166+
open.value = true;
167+
e.preventDefault();
168+
}
169+
}
162170
</script>
163171

164172
<template>
165173
<Popover v-model:open="open" :modal="false">
166174
<FormFieldLayout v-bind="props" v-slot="{ id, ariaDescribedBy }">
167175
<div class="relative">
168-
<PopoverTrigger as-child>
176+
<PopoverAnchor as-child>
169177
<Input
170178
:id="id"
171179
class="pl-10 min-w-full appearance-none text-left [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-date-and-time-value]:text-left"
@@ -181,10 +189,10 @@ function onMinuteChange(minute: string) {
181189
:model-value="inputValue"
182190
@update:model-value="onDateInput"
183191
@touchstart.passive="isTouch = true"
184-
@click.prevent="open = !isTouch"
192+
@click="onInputClick"
185193
ref="input"
186194
/>
187-
</PopoverTrigger>
195+
</PopoverAnchor>
188196
<div class="absolute right-px rounded-md top-px w-10 bottom-px bg-background hidden not-[@supports_selector(::-webkit-calendar-picker-indicator)]:block"
189197
@touchstart.passive="isTouch = true"
190198
@click="($refs.input.$el as HTMLInputElement).focus(); open = !isTouch"

0 commit comments

Comments
 (0)