Datepicker pops up in modal but auto close when click on anything in the datepick menu
See original GitHub issueI am using headless ui for modal dialog and the date picker is inside the modal. Initial focus is already set on the focusable button. When I click on the date picker component, it pops up the menu just fine, when I start to click anything on it, it closes.
Any advise?
Script setup code:
import { computed, reactive, ref } from 'vue';
import {
TransitionRoot,
TransitionChild,
Dialog,
DialogOverlay,
DialogTitle,
} from '@headlessui/vue';
import { XIcon } from '@heroicons/vue/outline';
import PrimaryButton from '@/Components/Commons/PrimaryButton';
const props = defineProps({
show: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['hide', 'confirm']);
const form = reactive({
starts_at: '',
ends_at: '',
});
const closeButtonRef = ref(null);
const hide = () => emit('hide');
const confirm = () => {
console.log('confirm');
};
Dialog(Modal) code:
<TransitionRoot as="template" :show="show">
<Dialog @close="hide()"
:initial-focus="closeButtonRef"
as="div"
class="fixed inset-0 z-10 overflow-hidden">
<div class="absolute inset-0 overflow-hidden">
<TransitionChild as="template"
enter="ease-in-out duration-300"
enter-from="opacity-0"
enter-to="opacity-100"
leave="ease-in-out duration-300"
leave-from="opacity-100"
leave-to="opacity-0">
<DialogOverlay class="absolute inset-0 bg-black bg-opacity-70 transition-opacity" />
</TransitionChild>
<div class="fixed inset-y-0 right-0 max-w-full flex">
<TransitionChild as="template"
enter="transform transition ease-in-out duration-300"
enter-from="translate-x-full"
enter-to="translate-x-0"
leave="transform transition ease-in-out duration-300"
leave-from="translate-x-0"
leave-to="translate-x-full">
<div class="panel-width">
<div class="h-full flex flex-col bg-white shadow-xl">
<div class="min-h-0 flex-1 pb-12 flex flex-col gap-y-4 overflow-y-scroll">
<!-- Header -->
<div class="p-6 bg-gray-50">
<div class="flex items-start justify-between">
<!-- Title -->
<DialogTitle class="text-lg text-gray-900">
Create Skill Training
</DialogTitle>
<!-- Close Button -->
<div class="ml-3 h-7 flex items-center">
<button ref="closeButtonRef"
@click="hide()"
type="button"
class="rounded-md text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<span class="sr-only">Close panel</span>
<XIcon class="h-6 w-6" aria-hidden="true" />
</button>
</div>
</div>
</div>
<!-- Content -->
<div class="mt-6 relative flex-1">
<form id="send-for-training-form" @submit.prevent="confirm()">
<section class="py-2 px-6 relative border border-red-500">
<!-- DATE PICKER HERE -->
<Datepicker v-model="form.starts_at" />
</section>
</form>
</div>
</div>
<!-- Footer -->
<div class="flex flex-shrink-0 border-t border-gray-200 px-6 py-5">
<PrimaryButton type="submit" class="ml-auto">
Send For Training
</PrimaryButton>
</div>
</div>
</div>
</TransitionChild>
</div>
</div>
</Dialog>
</TransitionRoot>
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
jQuery Datepicker close datepicker after selected date
When I click to datepicker it opens and I select any date. My question: If I choose date from datepicker, I want to...
Read more >DatePicker closes directly when used in Material-ui dialog
When I click the icon to toggle the DatePicker it just "bounces" or flashes, and is immediately closed. What could cause this behaviour?...
Read more >DatePicker not closing when clicking outside #25135 - GitHub
Click on the button that opens the picker; Click outside of it. Context. I want the DatePicker to auto close when clicking outside....
Read more >Datepicker in Angular using mat-datepicker | Material Design
Date picker is a component which allow users to choose a date from the calendar pop up or enter a date through text...
Read more >Datepicker | Angular Material
Label for the button used to close the calendar popup. nextMonthLabel: 'Next month' ... Gets the element that the datepicker popup should be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great, version 3.2 will include some adjustments where you wouldn’t need to change the teleport target or add initial focus
@donmb1 Will take a look