@finsweet/webflow-apps-utils 1.0.54 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
const handleGlobalKeyDown = (event: KeyboardEvent) => {
|
|
102
102
|
if (event.key === 'Escape' && closeOnEscape && isOpen) {
|
|
103
103
|
event.preventDefault();
|
|
104
|
+
event.stopPropagation();
|
|
104
105
|
closeDropdown();
|
|
105
106
|
// Remove focus to prevent focus ring after closing
|
|
106
107
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -334,7 +335,7 @@
|
|
|
334
335
|
if (!dropdownItems || !target) return instances;
|
|
335
336
|
|
|
336
337
|
if (closeOnClickOutside) {
|
|
337
|
-
document?.addEventListener('click', dismissTooltip);
|
|
338
|
+
document?.addEventListener('click', dismissTooltip, true);
|
|
338
339
|
}
|
|
339
340
|
instances.push(setupDropdown(target, dropdownItems));
|
|
340
341
|
|
|
@@ -347,7 +348,7 @@
|
|
|
347
348
|
const cleanupDropdownInstances = (instances: DropdownInstance[]) => {
|
|
348
349
|
instances.forEach((instance) => instance.cleanup());
|
|
349
350
|
if (closeOnClickOutside) {
|
|
350
|
-
document?.removeEventListener('click', dismissTooltip);
|
|
351
|
+
document?.removeEventListener('click', dismissTooltip, true);
|
|
351
352
|
}
|
|
352
353
|
};
|
|
353
354
|
|
|
@@ -477,10 +478,13 @@
|
|
|
477
478
|
</script>
|
|
478
479
|
|
|
479
480
|
{#snippet selectWrapper()}
|
|
481
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
482
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
480
483
|
<div
|
|
481
484
|
class="dropdown-wrapper {className}"
|
|
482
485
|
bind:this={dropdownWrapper}
|
|
483
486
|
style="{hide ? 'display:none;' : ''} width: {width};"
|
|
487
|
+
onclick={(e) => e.stopPropagation()}
|
|
484
488
|
>
|
|
485
489
|
<div
|
|
486
490
|
class="dropdown"
|
|
@@ -509,12 +513,14 @@
|
|
|
509
513
|
</div>
|
|
510
514
|
</div>
|
|
511
515
|
|
|
516
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
512
517
|
<div
|
|
513
518
|
tabindex={disabled || isOpen ? -1 : 0}
|
|
514
519
|
class="dropdown-list"
|
|
515
520
|
class:has-footer={footer}
|
|
516
521
|
role="listbox"
|
|
517
522
|
style="width:{dropdownWidth};"
|
|
523
|
+
onclick={(e) => e.stopPropagation()}
|
|
518
524
|
onkeydown={(e) => {
|
|
519
525
|
e.stopPropagation();
|
|
520
526
|
e.preventDefault();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import SelectInModalStory from './SelectInModalStory.svelte';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Ui/Select/InModal',
|
|
4
|
+
component: SelectInModalStory,
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: 'centered',
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: 'Testing Modal with Select component to ensure proper event handling'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
tags: ['autodocs']
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
export const Default = {
|
|
17
|
+
args: {}
|
|
18
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button } from '../button';
|
|
3
|
+
import Modal from '../modal/Modal.svelte';
|
|
4
|
+
import Select from './Select.svelte';
|
|
5
|
+
import type { SelectOption } from './types';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
initialOpen?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { initialOpen = false }: Props = $props();
|
|
12
|
+
|
|
13
|
+
let modalOpen = $state(initialOpen);
|
|
14
|
+
let selectedValue = $state<string | null>(null);
|
|
15
|
+
|
|
16
|
+
const options: SelectOption[] = [
|
|
17
|
+
{ label: 'Option 1', value: 'option1' },
|
|
18
|
+
{ label: 'Option 2', value: 'option2' },
|
|
19
|
+
{ label: 'Option 3', value: 'option3' },
|
|
20
|
+
{ label: 'Option 4', value: 'option4' },
|
|
21
|
+
{ label: 'Option 5', value: 'option5' }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const handleOpenModal = () => {
|
|
25
|
+
modalOpen = true;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const handleCloseModal = () => {
|
|
29
|
+
console.log('Modal closing');
|
|
30
|
+
modalOpen = false;
|
|
31
|
+
};
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<div style="padding: 20px;">
|
|
35
|
+
<Button onclick={handleOpenModal}>Open Modal with Select</Button>
|
|
36
|
+
|
|
37
|
+
<Modal
|
|
38
|
+
open={modalOpen}
|
|
39
|
+
onOpenChange={(open) => {
|
|
40
|
+
console.log('Modal onOpenChange:', open);
|
|
41
|
+
modalOpen = open;
|
|
42
|
+
}}
|
|
43
|
+
title="Select Example Inside Modal"
|
|
44
|
+
showFooter={false}
|
|
45
|
+
width="400px"
|
|
46
|
+
closeOnOverlayClick={false}
|
|
47
|
+
closeOnEscape={false}
|
|
48
|
+
>
|
|
49
|
+
<div style="padding: 20px; display: flex; flex-direction: column; gap: 16px;">
|
|
50
|
+
<p style="color: var(--text1); margin: 0;">Test the following behaviors:</p>
|
|
51
|
+
<ul style="color: var(--text2); margin: 0; padding-left: 20px;">
|
|
52
|
+
<li>Click outside the modal (overlay) - modal stays open (disabled)</li>
|
|
53
|
+
<li>Press Escape with select closed - modal stays open (disabled)</li>
|
|
54
|
+
<li>Press Escape with select open - should close select only</li>
|
|
55
|
+
<li>Click outside select but inside modal - should close select only</li>
|
|
56
|
+
<li>Use "Close Modal" button to close the modal</li>
|
|
57
|
+
</ul>
|
|
58
|
+
|
|
59
|
+
<Select
|
|
60
|
+
{options}
|
|
61
|
+
bind:selected={selectedValue}
|
|
62
|
+
defaultText="Choose an option"
|
|
63
|
+
width="100%"
|
|
64
|
+
dropdownWidth="100%"
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
{#if selectedValue}
|
|
68
|
+
<p style="color: var(--text1); margin: 0;">
|
|
69
|
+
Selected: {selectedValue}
|
|
70
|
+
</p>
|
|
71
|
+
{/if}
|
|
72
|
+
|
|
73
|
+
<Button onclick={handleCloseModal} variant="secondary">Close Modal</Button>
|
|
74
|
+
</div>
|
|
75
|
+
</Modal>
|
|
76
|
+
</div>
|