@crowdstrike/glide-core 0.12.1 → 0.12.3
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.
- package/dist/checkbox-group.styles.js +1 -1
- package/dist/dropdown.d.ts +5 -1
- package/dist/dropdown.js +126 -58
- package/dist/dropdown.option.d.ts +3 -0
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +81 -16
- package/dist/dropdown.option.test.basics.js +4 -33
- package/dist/dropdown.option.test.basics.multiple.js +9 -0
- package/dist/dropdown.option.test.basics.single.js +8 -0
- package/dist/dropdown.option.test.interactions.multiple.js +12 -0
- package/dist/dropdown.option.test.interactions.single.js +11 -0
- package/dist/dropdown.styles.js +127 -29
- package/dist/dropdown.test.basics.filterable.js +11 -54
- package/dist/dropdown.test.basics.js +24 -244
- package/dist/dropdown.test.basics.multiple.js +13 -60
- package/dist/dropdown.test.basics.single.js +2 -8
- package/dist/dropdown.test.events.filterable.js +12 -54
- package/dist/dropdown.test.events.js +139 -46
- package/dist/dropdown.test.events.multiple.js +17 -87
- package/dist/dropdown.test.events.single.js +99 -60
- package/dist/dropdown.test.focus.filterable.js +13 -60
- package/dist/dropdown.test.focus.js +64 -11
- package/dist/dropdown.test.focus.multiple.js +36 -46
- package/dist/dropdown.test.focus.single.js +28 -23
- package/dist/dropdown.test.form.js +22 -0
- package/dist/dropdown.test.interactions.filterable.js +86 -72
- package/dist/dropdown.test.interactions.js +361 -207
- package/dist/dropdown.test.interactions.multiple.js +152 -279
- package/dist/dropdown.test.interactions.single.js +62 -98
- package/dist/dropdown.test.validity.js +12 -49
- package/dist/icons/pencil.d.ts +2 -0
- package/dist/icons/pencil.js +1 -0
- package/dist/label.js +1 -1
- package/dist/label.styles.js +7 -3
- package/dist/library/localize.d.ts +2 -0
- package/dist/menu.js +1 -1
- package/dist/menu.options.js +1 -1
- package/dist/menu.options.test.events.d.ts +1 -0
- package/dist/menu.options.test.events.js +19 -0
- package/dist/menu.test.interactions.d.ts +1 -0
- package/dist/menu.test.interactions.js +38 -0
- package/dist/radio-group.styles.js +1 -1
- package/dist/tab.group.d.ts +8 -1
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.styles.js +4 -0
- package/dist/tab.group.test.basics.js +77 -1
- package/dist/tab.panel.js +1 -1
- package/dist/tab.panel.styles.js +15 -0
- package/dist/tag.d.ts +2 -0
- package/dist/tag.js +1 -1
- package/dist/tag.styles.js +46 -5
- package/dist/tag.test.basics.js +1 -1
- package/dist/tag.test.events.js +76 -3
- package/dist/tag.test.focus.js +1 -1
- package/dist/textarea.styles.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.d.ts +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.d.ts +1 -1
- package/dist/translations/ja.js +1 -1
- package/package.json +1 -1
@@ -1,25 +1,18 @@
|
|
1
1
|
import './dropdown.option.js';
|
2
|
-
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
|
2
|
+
import { aTimeout, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
|
3
3
|
import GlideCoreDropdown from './dropdown.js';
|
4
4
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
5
5
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
6
6
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
7
|
-
it('focuses the button when `focus()` is called', async () => {
|
7
|
+
it('focuses the primary button when `focus()` is called', async () => {
|
8
8
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
9
|
-
<glide-core-dropdown-option
|
10
|
-
|
11
|
-
value="one"
|
12
|
-
></glide-core-dropdown-option>
|
13
|
-
|
14
|
-
<glide-core-dropdown-option
|
15
|
-
label="Two"
|
16
|
-
value="two"
|
17
|
-
></glide-core-dropdown-option>
|
9
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
18
11
|
</glide-core-dropdown>`);
|
19
12
|
component.focus();
|
20
|
-
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="button"]'));
|
13
|
+
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="primary-button"]'));
|
21
14
|
});
|
22
|
-
it('focuses the button on submit when required and no options are selected', async () => {
|
15
|
+
it('focuses the primary button on submit when required and no options are selected', async () => {
|
23
16
|
const form = document.createElement('form');
|
24
17
|
const component = await fixture(html `<glide-core-dropdown
|
25
18
|
label="Label"
|
@@ -27,23 +20,17 @@ it('focuses the button on submit when required and no options are selected', asy
|
|
27
20
|
multiple
|
28
21
|
required
|
29
22
|
>
|
30
|
-
<glide-core-dropdown-option
|
31
|
-
label="One"
|
32
|
-
value="one"
|
33
|
-
></glide-core-dropdown-option>
|
23
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
34
24
|
|
35
|
-
<glide-core-dropdown-option
|
36
|
-
label="Two"
|
37
|
-
value="two"
|
38
|
-
></glide-core-dropdown-option>
|
25
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
39
26
|
</glide-core-dropdown>`, {
|
40
27
|
parentNode: form,
|
41
28
|
});
|
42
29
|
form.requestSubmit();
|
43
|
-
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
30
|
+
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
44
31
|
expect(component.shadowRoot?.activeElement).to.be.equal(button);
|
45
32
|
});
|
46
|
-
it('focuses the button when `reportValidity` is called when required and no options are selected', async () => {
|
33
|
+
it('focuses the primary button when `reportValidity` is called when required and no options are selected', async () => {
|
47
34
|
const form = document.createElement('form');
|
48
35
|
const component = await fixture(html `<glide-core-dropdown
|
49
36
|
label="Label"
|
@@ -51,21 +38,14 @@ it('focuses the button when `reportValidity` is called when required and no opti
|
|
51
38
|
multiple
|
52
39
|
required
|
53
40
|
>
|
54
|
-
<glide-core-dropdown-option
|
55
|
-
|
56
|
-
value="one"
|
57
|
-
></glide-core-dropdown-option>
|
58
|
-
|
59
|
-
<glide-core-dropdown-option
|
60
|
-
label="Two"
|
61
|
-
value="two"
|
62
|
-
></glide-core-dropdown-option>
|
41
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
42
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
63
43
|
</glide-core-dropdown>`, { parentNode: form });
|
64
44
|
component.reportValidity();
|
65
|
-
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
45
|
+
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
66
46
|
expect(component.shadowRoot?.activeElement).to.equal(button);
|
67
47
|
});
|
68
|
-
it('does not focus the button when `checkValidity` is called', async () => {
|
48
|
+
it('does not focus the primary button when `checkValidity` is called', async () => {
|
69
49
|
const form = document.createElement('form');
|
70
50
|
const component = await fixture(html `<glide-core-dropdown
|
71
51
|
label="Label"
|
@@ -75,13 +55,11 @@ it('does not focus the button when `checkValidity` is called', async () => {
|
|
75
55
|
>
|
76
56
|
<glide-core-dropdown-option
|
77
57
|
label="One"
|
78
|
-
value="one"
|
79
58
|
selected
|
80
59
|
></glide-core-dropdown-option>
|
81
60
|
|
82
61
|
<glide-core-dropdown-option
|
83
62
|
label="Two"
|
84
|
-
value="two"
|
85
63
|
selected
|
86
64
|
></glide-core-dropdown-option>
|
87
65
|
</glide-core-dropdown>`, { parentNode: form });
|
@@ -97,25 +75,24 @@ it('focuses the second tag when the first one is removed', async () => {
|
|
97
75
|
>
|
98
76
|
<glide-core-dropdown-option
|
99
77
|
label="One"
|
100
|
-
value="one"
|
101
78
|
selected
|
102
79
|
></glide-core-dropdown-option>
|
103
80
|
|
104
81
|
<glide-core-dropdown-option
|
105
82
|
label="Two"
|
106
|
-
value="two"
|
107
83
|
selected
|
108
84
|
></glide-core-dropdown-option>
|
109
85
|
|
110
86
|
<glide-core-dropdown-option
|
111
87
|
label="Three"
|
112
|
-
value="three"
|
113
88
|
selected
|
114
89
|
></glide-core-dropdown-option>
|
115
90
|
</glide-core-dropdown>`);
|
116
91
|
const tags = component.shadowRoot?.querySelectorAll('[data-test="tag"]');
|
117
92
|
tags?.[0].click();
|
118
93
|
await elementUpdated(component);
|
94
|
+
// Wait for the timeout in `#onTagRemove`.
|
95
|
+
await aTimeout(0);
|
119
96
|
expect(component.shadowRoot?.activeElement).to.equal(tags?.[1]);
|
120
97
|
});
|
121
98
|
it('focuses the third tag when the second one is removed', async () => {
|
@@ -127,28 +104,27 @@ it('focuses the third tag when the second one is removed', async () => {
|
|
127
104
|
>
|
128
105
|
<glide-core-dropdown-option
|
129
106
|
label="One"
|
130
|
-
value="one"
|
131
107
|
selected
|
132
108
|
></glide-core-dropdown-option>
|
133
109
|
|
134
110
|
<glide-core-dropdown-option
|
135
111
|
label="Two"
|
136
|
-
value="two"
|
137
112
|
selected
|
138
113
|
></glide-core-dropdown-option>
|
139
114
|
|
140
115
|
<glide-core-dropdown-option
|
141
116
|
label="Three"
|
142
|
-
value="three"
|
143
117
|
selected
|
144
118
|
></glide-core-dropdown-option>
|
145
119
|
</glide-core-dropdown>`);
|
146
120
|
const tags = component.shadowRoot?.querySelectorAll('[data-test="tag"]');
|
147
121
|
tags?.[1].click();
|
148
122
|
await elementUpdated(component);
|
123
|
+
// Wait for the timeout in `#onTagRemove`.
|
124
|
+
await aTimeout(0);
|
149
125
|
expect(component.shadowRoot?.activeElement).to.equal(tags?.[2]);
|
150
126
|
});
|
151
|
-
it('focuses the second tag when the
|
127
|
+
it('focuses the second tag when the third tag removed', async () => {
|
152
128
|
const component = await fixture(html `<glide-core-dropdown
|
153
129
|
label="Label"
|
154
130
|
placeholder="Placeholder"
|
@@ -157,24 +133,38 @@ it('focuses the second tag when the last one removed', async () => {
|
|
157
133
|
>
|
158
134
|
<glide-core-dropdown-option
|
159
135
|
label="One"
|
160
|
-
value="one"
|
161
136
|
selected
|
162
137
|
></glide-core-dropdown-option>
|
163
138
|
|
164
139
|
<glide-core-dropdown-option
|
165
140
|
label="Two"
|
166
|
-
value="two"
|
167
141
|
selected
|
168
142
|
></glide-core-dropdown-option>
|
169
143
|
|
170
144
|
<glide-core-dropdown-option
|
171
145
|
label="Three"
|
172
|
-
value="three"
|
173
146
|
selected
|
174
147
|
></glide-core-dropdown-option>
|
175
148
|
</glide-core-dropdown>`);
|
176
149
|
const tags = component.shadowRoot?.querySelectorAll('[data-test="tag"]');
|
177
150
|
tags?.[2].click();
|
178
151
|
await elementUpdated(component);
|
152
|
+
// Wait for the timeout in `#onTagRemove`.
|
153
|
+
await aTimeout(0);
|
179
154
|
expect(component.shadowRoot?.activeElement).to.equal(tags?.[1]);
|
180
155
|
});
|
156
|
+
it('focuses itself when the last tag is removed', async () => {
|
157
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
158
|
+
<glide-core-dropdown-option
|
159
|
+
label="One"
|
160
|
+
selected
|
161
|
+
></glide-core-dropdown-option>
|
162
|
+
</glide-core-dropdown>`);
|
163
|
+
component.shadowRoot
|
164
|
+
?.querySelector('[data-test="tag"]')
|
165
|
+
?.click();
|
166
|
+
await elementUpdated(component);
|
167
|
+
// Wait for the timeout in `#onTagRemove`.
|
168
|
+
await aTimeout(0);
|
169
|
+
expect(document.activeElement).to.equal(component);
|
170
|
+
});
|
@@ -1,53 +1,58 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
1
2
|
import './dropdown.option.js';
|
2
|
-
import { expect, fixture, html } from '@open-wc/testing';
|
3
|
+
import { aTimeout, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
|
3
4
|
import GlideCoreDropdown from './dropdown.js';
|
4
5
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
5
6
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
6
7
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
7
|
-
it('focuses the button when `focus()` is called', async () => {
|
8
|
+
it('focuses the primary button when `focus()` is called', async () => {
|
8
9
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
9
|
-
<glide-core-dropdown-option
|
10
|
-
label="Label"
|
11
|
-
value="value"
|
12
|
-
></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
13
11
|
</glide-core-dropdown>`);
|
14
12
|
component.focus();
|
15
|
-
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="button"]'));
|
13
|
+
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="primary-button"]'));
|
16
14
|
});
|
17
15
|
it('focuses the button on submit', async () => {
|
18
16
|
const form = document.createElement('form');
|
19
17
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
20
|
-
<glide-core-dropdown-option
|
21
|
-
label="Label"
|
22
|
-
value="value"
|
23
|
-
></glide-core-dropdown-option>
|
18
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
24
19
|
</glide-core-dropdown>`, {
|
25
20
|
parentNode: form,
|
26
21
|
});
|
27
22
|
form.requestSubmit();
|
28
|
-
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
23
|
+
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
29
24
|
expect(component.shadowRoot?.activeElement).to.be.equal(button);
|
30
25
|
});
|
31
|
-
it('focuses the button when `reportValidity` is called when required and no option is selected', async () => {
|
26
|
+
it('focuses the primary button when `reportValidity` is called when required and no option is selected', async () => {
|
32
27
|
const form = document.createElement('form');
|
33
28
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
34
|
-
<glide-core-dropdown-option
|
35
|
-
label="Label"
|
36
|
-
value="value"
|
37
|
-
></glide-core-dropdown-option>
|
29
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
38
30
|
</glide-core-dropdown>`, { parentNode: form });
|
39
31
|
component.reportValidity();
|
40
|
-
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
32
|
+
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
41
33
|
expect(component.shadowRoot?.activeElement).to.equal(button);
|
42
34
|
});
|
43
|
-
it('does not focus the button when `checkValidity` is called', async () => {
|
35
|
+
it('does not focus the primary button when `checkValidity` is called', async () => {
|
44
36
|
const form = document.createElement('form');
|
45
37
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
46
|
-
<glide-core-dropdown-option
|
47
|
-
label="Label"
|
48
|
-
value="value"
|
49
|
-
></glide-core-dropdown-option>
|
38
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
50
39
|
</glide-core-dropdown>`, { parentNode: form });
|
51
40
|
component.checkValidity();
|
52
41
|
expect(component.shadowRoot?.activeElement).to.equal(null);
|
53
42
|
});
|
43
|
+
it('has a tooltip on focus when its internal label is overflowing', async () => {
|
44
|
+
// The period is arbitrary. 500 of them ensures we overflow.
|
45
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
46
|
+
<glide-core-dropdown-option
|
47
|
+
label=${'.'.repeat(500)}
|
48
|
+
selected
|
49
|
+
></glide-core-dropdown-option>
|
50
|
+
</glide-core-dropdown>`);
|
51
|
+
component.focus();
|
52
|
+
await elementUpdated(component);
|
53
|
+
// Wait for the Resize Observer to do its thing.
|
54
|
+
await aTimeout(0);
|
55
|
+
const tooltip = component.shadowRoot?.querySelector('[data-test="internal-label-tooltip"]');
|
56
|
+
expect(tooltip?.open).to.be.true;
|
57
|
+
expect(tooltip?.disabled).to.be.false;
|
58
|
+
});
|
@@ -50,3 +50,25 @@ it('does not submit its form on Enter when open', async () => {
|
|
50
50
|
await sendKeys({ press: 'Enter' });
|
51
51
|
expect(spy.callCount).to.equal(0);
|
52
52
|
});
|
53
|
+
it('does not submit its form when Enter is pressed on the Edit button', async () => {
|
54
|
+
const form = document.createElement('form');
|
55
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
56
|
+
<glide-core-dropdown-option
|
57
|
+
label="Label"
|
58
|
+
editable
|
59
|
+
selected
|
60
|
+
></glide-core-dropdown-option>
|
61
|
+
</glide-core-dropdown>`, {
|
62
|
+
parentNode: form,
|
63
|
+
});
|
64
|
+
const spy = sinon.spy();
|
65
|
+
form.addEventListener('submit', (event) => {
|
66
|
+
event.preventDefault();
|
67
|
+
spy();
|
68
|
+
});
|
69
|
+
component.shadowRoot
|
70
|
+
?.querySelector('[data-test="edit-button"]')
|
71
|
+
?.focus();
|
72
|
+
await sendKeys({ press: 'Enter' });
|
73
|
+
expect(spy.callCount).to.equal(0);
|
74
|
+
});
|
@@ -6,60 +6,17 @@ import GlideCoreDropdownOption from './dropdown.option.js';
|
|
6
6
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
7
7
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
8
8
|
const defaultSlot = html `
|
9
|
-
<glide-core-dropdown-option
|
10
|
-
|
11
|
-
|
12
|
-
></glide-core-dropdown-option>
|
13
|
-
|
14
|
-
<glide-core-dropdown-option
|
15
|
-
|
16
|
-
|
17
|
-
></glide-core-dropdown-option>
|
18
|
-
|
19
|
-
<glide-core-dropdown-option
|
20
|
-
label="Three"
|
21
|
-
value="three"
|
22
|
-
></glide-core-dropdown-option>
|
23
|
-
|
24
|
-
<glide-core-dropdown-option
|
25
|
-
label="Four"
|
26
|
-
value="four"
|
27
|
-
></glide-core-dropdown-option>
|
28
|
-
|
29
|
-
<glide-core-dropdown-option
|
30
|
-
label="Five"
|
31
|
-
value="five"
|
32
|
-
></glide-core-dropdown-option>
|
33
|
-
|
34
|
-
<glide-core-dropdown-option
|
35
|
-
label="Six"
|
36
|
-
value="six"
|
37
|
-
></glide-core-dropdown-option>
|
38
|
-
|
39
|
-
<glide-core-dropdown-option
|
40
|
-
label="Seven"
|
41
|
-
value="seven"
|
42
|
-
></glide-core-dropdown-option>
|
43
|
-
|
44
|
-
<glide-core-dropdown-option
|
45
|
-
label="Eight"
|
46
|
-
value="eight"
|
47
|
-
></glide-core-dropdown-option>
|
48
|
-
|
49
|
-
<glide-core-dropdown-option
|
50
|
-
label="Nine"
|
51
|
-
value="nine"
|
52
|
-
></glide-core-dropdown-option>
|
53
|
-
|
54
|
-
<glide-core-dropdown-option
|
55
|
-
label="Ten"
|
56
|
-
value="ten"
|
57
|
-
></glide-core-dropdown-option>
|
58
|
-
|
59
|
-
<glide-core-dropdown-option
|
60
|
-
label="Eleven"
|
61
|
-
value="eleven"
|
62
|
-
></glide-core-dropdown-option>
|
9
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
11
|
+
<glide-core-dropdown-option label="Three"></glide-core-dropdown-option>
|
12
|
+
<glide-core-dropdown-option label="Four"></glide-core-dropdown-option>
|
13
|
+
<glide-core-dropdown-option label="Five"></glide-core-dropdown-option>
|
14
|
+
<glide-core-dropdown-option label="Six"></glide-core-dropdown-option>
|
15
|
+
<glide-core-dropdown-option label="Seven"></glide-core-dropdown-option>
|
16
|
+
<glide-core-dropdown-option label="Eight"></glide-core-dropdown-option>
|
17
|
+
<glide-core-dropdown-option label="Nine"></glide-core-dropdown-option>
|
18
|
+
<glide-core-dropdown-option label="Ten"></glide-core-dropdown-option>
|
19
|
+
<glide-core-dropdown-option label="Eleven"></glide-core-dropdown-option>
|
63
20
|
`;
|
64
21
|
it('opens on click', async () => {
|
65
22
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
@@ -218,6 +175,56 @@ it('hides its magnifying glass icon when multiselect and not filtering', async (
|
|
218
175
|
const icon = component?.shadowRoot?.querySelector('[data-test="magnifying-glass-icon"]');
|
219
176
|
expect(icon?.checkVisibility()).to.be.not.ok;
|
220
177
|
});
|
178
|
+
it('does not clear its filter when a tag is removed via Backspace', async () => {
|
179
|
+
const component = await fixture(html `<glide-core-dropdown
|
180
|
+
label="Label"
|
181
|
+
placeholder="Placeholder"
|
182
|
+
filterable
|
183
|
+
multiple
|
184
|
+
>
|
185
|
+
<glide-core-dropdown-option
|
186
|
+
label="One"
|
187
|
+
selected
|
188
|
+
></glide-core-dropdown-option>
|
189
|
+
|
190
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
191
|
+
</glide-core-dropdown>`);
|
192
|
+
// Wait for it to open.
|
193
|
+
await aTimeout(0);
|
194
|
+
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
195
|
+
input?.select();
|
196
|
+
input?.focus();
|
197
|
+
await sendKeys({ type: 'o' });
|
198
|
+
await sendKeys({ press: 'ArrowLeft' });
|
199
|
+
await sendKeys({ press: 'Backspace' });
|
200
|
+
expect(input?.value).to.equal('o');
|
201
|
+
});
|
202
|
+
it('does not clear its filter when every tag is removed via Meta + Backspace', async () => {
|
203
|
+
const component = await fixture(html `<glide-core-dropdown
|
204
|
+
label="Label"
|
205
|
+
placeholder="Placeholder"
|
206
|
+
filterable
|
207
|
+
multiple
|
208
|
+
>
|
209
|
+
<glide-core-dropdown-option
|
210
|
+
label="One"
|
211
|
+
selected
|
212
|
+
></glide-core-dropdown-option>
|
213
|
+
|
214
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
215
|
+
</glide-core-dropdown>`);
|
216
|
+
// Wait for it to open.
|
217
|
+
await aTimeout(0);
|
218
|
+
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
219
|
+
input?.select();
|
220
|
+
input?.focus();
|
221
|
+
await sendKeys({ type: 'o' });
|
222
|
+
await sendKeys({ press: 'ArrowLeft' });
|
223
|
+
await sendKeys({ down: 'Meta' });
|
224
|
+
await sendKeys({ press: 'Backspace' });
|
225
|
+
await sendKeys({ up: 'Meta' });
|
226
|
+
expect(input?.value).to.equal('o');
|
227
|
+
});
|
221
228
|
it('does not filter on only whitespace', async () => {
|
222
229
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
223
230
|
${defaultSlot}
|
@@ -275,7 +282,7 @@ it('sets the first unfiltered option as active when the previously active option
|
|
275
282
|
expect(option?.privateActive).to.be.true;
|
276
283
|
expect(input?.getAttribute('aria-activedescendant')).to.equal(option?.id);
|
277
284
|
});
|
278
|
-
it('updates the `value` of its `<input>` when
|
285
|
+
it('updates the `value` of its `<input>` when `label` of a selected option is changed programmatically', async () => {
|
279
286
|
const component = await fixture(html `<glide-core-dropdown
|
280
287
|
label="Label"
|
281
288
|
placeholder="Placeholder"
|
@@ -308,14 +315,10 @@ it('sets the `value` of its `<input>` when made filterable', async () => {
|
|
308
315
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
309
316
|
<glide-core-dropdown-option
|
310
317
|
label="One"
|
311
|
-
value="one"
|
312
318
|
selected
|
313
319
|
></glide-core-dropdown-option>
|
314
320
|
|
315
|
-
<glide-core-dropdown-option
|
316
|
-
label="Two"
|
317
|
-
value="two"
|
318
|
-
></glide-core-dropdown-option>
|
321
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
319
322
|
</glide-core-dropdown>`);
|
320
323
|
component.filterable = true;
|
321
324
|
await elementUpdated(component);
|
@@ -350,7 +353,6 @@ it('deselects the last selected option on Backspace', async () => {
|
|
350
353
|
component.shadowRoot
|
351
354
|
?.querySelector('[data-test="input"]')
|
352
355
|
?.setSelectionRange(0, 0);
|
353
|
-
await aTimeout(0);
|
354
356
|
await sendKeys({ press: 'Backspace' });
|
355
357
|
expect(options[1].selected).to.be.false;
|
356
358
|
expect(options[0].selected).to.be.true;
|
@@ -395,6 +397,22 @@ it('clears the `value` of its `<input>` when multiselect and an option is select
|
|
395
397
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
396
398
|
expect(input?.value).to.be.empty.string;
|
397
399
|
});
|
400
|
+
it('does not clear its filter when a tag is removed', async () => {
|
401
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
402
|
+
${defaultSlot}
|
403
|
+
</glide-core-dropdown>`);
|
404
|
+
const option = component.querySelector('glide-core-dropdown-option');
|
405
|
+
assert(option);
|
406
|
+
option.selected = true;
|
407
|
+
component.focus();
|
408
|
+
await sendKeys({ type: 'one' });
|
409
|
+
component.shadowRoot
|
410
|
+
?.querySelector('[data-test="tag"]')
|
411
|
+
?.click();
|
412
|
+
await elementUpdated(component);
|
413
|
+
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
414
|
+
expect(input?.value).to.equal('one');
|
415
|
+
});
|
398
416
|
it('uses `placeholder` as a placeholder when multiselect and no option is selected', async () => {
|
399
417
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
400
418
|
${defaultSlot}
|
@@ -512,7 +530,7 @@ it('sets `aria-activedescendant` on open via click', async () => {
|
|
512
530
|
// and would work. `CustomEvent` is used for completeness and to get us as close as
|
513
531
|
// possible to a real click. See the comment in the handler for more information.
|
514
532
|
component.shadowRoot
|
515
|
-
?.querySelector('[data-test="button"]')
|
533
|
+
?.querySelector('[data-test="primary-button"]')
|
516
534
|
?.dispatchEvent(new CustomEvent('click', { bubbles: true, detail: 1 }));
|
517
535
|
// Wait for it to open.
|
518
536
|
await aTimeout(0);
|
@@ -597,11 +615,11 @@ it('sets `aria-activedescendant` when closed via click', async () => {
|
|
597
615
|
${defaultSlot}
|
598
616
|
</glide-core-dropdown>`);
|
599
617
|
component.shadowRoot
|
600
|
-
?.querySelector('[data-test="button"]')
|
618
|
+
?.querySelector('[data-test="primary-button"]')
|
601
619
|
?.click();
|
602
620
|
await elementUpdated(component);
|
603
621
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
604
|
-
expect(input?.getAttribute('aria-activedescendant')).to.
|
622
|
+
expect(input?.getAttribute('aria-activedescendant')).to.be.empty.string;
|
605
623
|
});
|
606
624
|
it('sets `aria-activedescendant` when closed because it lost focus', async () => {
|
607
625
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
@@ -610,7 +628,7 @@ it('sets `aria-activedescendant` when closed because it lost focus', async () =>
|
|
610
628
|
component.focus();
|
611
629
|
await sendKeys({ press: 'Tab' });
|
612
630
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
613
|
-
expect(input?.getAttribute('aria-activedescendant')).to.
|
631
|
+
expect(input?.getAttribute('aria-activedescendant')).to.be.empty.string;
|
614
632
|
});
|
615
633
|
it('sets `aria-activedescendant` when closed because something outside of it was clicked', async () => {
|
616
634
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
@@ -619,7 +637,7 @@ it('sets `aria-activedescendant` when closed because something outside of it was
|
|
619
637
|
document.body.click();
|
620
638
|
await elementUpdated(component);
|
621
639
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
622
|
-
expect(input?.getAttribute('aria-activedescendant')).to.
|
640
|
+
expect(input?.getAttribute('aria-activedescendant')).to.be.empty.string;
|
623
641
|
});
|
624
642
|
it('sets `aria-activedescendant` when closed via Escape', async () => {
|
625
643
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
@@ -628,7 +646,7 @@ it('sets `aria-activedescendant` when closed via Escape', async () => {
|
|
628
646
|
component.focus();
|
629
647
|
await sendKeys({ press: 'Escape' });
|
630
648
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
631
|
-
expect(input?.getAttribute('aria-activedescendant')).to.
|
649
|
+
expect(input?.getAttribute('aria-activedescendant')).to.be.empty.string;
|
632
650
|
});
|
633
651
|
it('cannot be tabbed to when `disabled`', async () => {
|
634
652
|
await fixture(html `<glide-core-dropdown
|
@@ -691,14 +709,10 @@ it('has no icon when filtering and an option is selected', async () => {
|
|
691
709
|
|
692
710
|
<glide-core-dropdown-option
|
693
711
|
label="One"
|
694
|
-
value="one"
|
695
712
|
selected
|
696
713
|
></glide-core-dropdown-option>
|
697
714
|
|
698
|
-
<glide-core-dropdown-option
|
699
|
-
label="Two"
|
700
|
-
value="two"
|
701
|
-
></glide-core-dropdown-option>
|
715
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
702
716
|
</glide-core-dropdown>`);
|
703
717
|
component.focus();
|
704
718
|
await sendKeys({ type: 'one' });
|