Skip to content

Commit c4daca3

Browse files
committed
add modal focus trap & fix design bug in project billable section
1 parent 4e10f95 commit c4daca3

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

resources/js/packages/ui/src/Modal.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script setup lang="ts">
2-
import { computed, onMounted, onUnmounted, watch } from 'vue';
2+
import { computed, nextTick, onMounted, onUnmounted, watch } from 'vue';
33
import { useId } from 'radix-vue';
44
import { isLastLayer, layers } from '@/packages/ui/src/utils/dismissableLayer';
5+
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap';
6+
import { ref } from 'vue';
57
68
const props = defineProps({
79
show: {
@@ -74,6 +76,23 @@ const maxWidthClass = computed(() => {
7476
'2xl': 'sm:max-w-2xl',
7577
}[props.maxWidth];
7678
});
79+
80+
const target = ref();
81+
const { activate, deactivate } = useFocusTrap(target);
82+
watch(
83+
() => props.show,
84+
(value) => {
85+
if (value) {
86+
nextTick(() => {
87+
activate();
88+
});
89+
} else {
90+
nextTick(() => {
91+
deactivate();
92+
});
93+
}
94+
}
95+
);
7796
</script>
7897

7998
<template>
@@ -109,6 +128,7 @@ const maxWidthClass = computed(() => {
109128
<div
110129
v-show="show"
111130
role="dialog"
131+
ref="target"
112132
class="mb-6 bg-default-background border border-card-border rounded-lg shadow-xl transform transition-all sm:w-full sm:mx-auto"
113133
:class="maxWidthClass">
114134
<slot v-if="show" />

resources/js/packages/ui/src/Project/ProjectEditBillableSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const emit = defineEmits(['submit']);
5757
<template>
5858
<div class="sm:flex items-center space-y-2 sm:space-y-0 sm:space-x-4 pt-6">
5959
<div>
60-
<div class="flex items-center space-x-1">
60+
<div class="flex items-center space-x-1 mb-2">
6161
<BillableIcon
6262
class="text-text-quaternary h-4 ml-1 mr-0.5"></BillableIcon>
6363
<InputLabel for="billable" value="Billable Default" />

0 commit comments

Comments
 (0)