Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Change Inertia Modal.vue component to use a native <dialog> #1431

Merged
merged 6 commits into from
Feb 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added second ref for showing the slot to stop content from appearing …
…and disappearing, preventing modal size shifting
  • Loading branch information
Smef committed Feb 15, 2024
commit 321473dc16917442cb7fe02fbe4af9190bec2884
5 changes: 4 additions & 1 deletion stubs/inertia/resources/js/Components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ const props = defineProps({

const emit = defineEmits(['close']);
const dialog = ref();
const showSlot = ref(props.show);

watch(() => props.show, () => {
if (props.show) {
document.body.style.overflow = 'hidden';
showSlot.value = true;
dialog.value?.showModal();
} else {
document.body.style.overflow = null;
setTimeout(() => {
dialog.value?.close();
showSlot.value = false;
}, 200);
}
});
Expand Down Expand Up @@ -87,7 +90,7 @@ const maxWidthClass = computed(() => {
leave-to-class="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<div v-show="show" class="mb-6 bg-white dark:bg-gray-800 rounded-lg overflow-hidden shadow-xl transform transition-all sm:w-full sm:mx-auto" :class="maxWidthClass">
<slot v-if="show"/>
<slot v-if="showSlot"/>
</div>
</transition>
</div>
Expand Down
Loading