fix tests, add autofocus disable option for dropdown

This commit is contained in:
Gregor Vostrak
2025-04-15 15:18:02 +02:00
parent d03dd60864
commit 15ac3e9a43
13 changed files with 37 additions and 32 deletions

View File

@@ -10,7 +10,6 @@ withDefaults(
}
);
</script>
Modal.vue
<template>
<button
:type="type"

View File

@@ -5,18 +5,23 @@ const props = withDefaults(
defineProps<{
align?: 'center' | 'end' | 'start';
closeOnContentClick?: boolean;
autoFocus?: boolean;
}>(),
{
align: 'start',
closeOnContentClick: true,
autoFocus: true,
}
);
const emit = defineEmits(['open', 'submit']);
const open = defineModel({ default: false });
function handleAutofocus(event: Event) {
if (props.autoFocus === false) {
event.preventDefault();
}
}
function onContentClick() {
if (props.closeOnContentClick === true) {
@@ -42,6 +47,7 @@ function onOpenChange(value: boolean) {
<PopoverContent
:align="align"
class="rounded-lg overflow-hidden relative border border-card-border overflow-none shadow-dropdown bg-card-background"
@open-auto-focus="handleAutofocus"
@click="onContentClick">
<slot name="content" />
</PopoverContent>

View File

@@ -171,6 +171,7 @@ function closeAndFocusInput() {
<Dropdown
v-model="open"
align="center"
:auto-focus="false"
:close-on-content-click="false"
@submit="open = false">
<template #trigger>