@crowdstrike/glide-core 0.12.2 → 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 +4 -1
- package/dist/dropdown.js +107 -55
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +4 -2
- package/dist/dropdown.option.test.interactions.multiple.js +2 -2
- package/dist/dropdown.option.test.interactions.single.js +2 -2
- package/dist/dropdown.styles.js +108 -13
- 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 +75 -49
- package/dist/dropdown.test.events.multiple.js +17 -87
- package/dist/dropdown.test.events.single.js +12 -60
- package/dist/dropdown.test.focus.filterable.js +11 -58
- package/dist/dropdown.test.focus.js +62 -9
- package/dist/dropdown.test.focus.multiple.js +22 -38
- package/dist/dropdown.test.focus.single.js +22 -17
- package/dist/dropdown.test.interactions.filterable.js +83 -69
- package/dist/dropdown.test.interactions.js +225 -243
- package/dist/dropdown.test.interactions.multiple.js +78 -274
- package/dist/dropdown.test.interactions.single.js +20 -85
- package/dist/dropdown.test.validity.js +12 -49
- package/dist/label.js +1 -1
- package/dist/label.styles.js +7 -3
- package/dist/radio-group.styles.js +1 -1
- package/dist/tab.group.styles.js +0 -6
- package/dist/tab.panel.styles.js +0 -3
- package/dist/textarea.styles.js +1 -1
- package/package.json +1 -1
@@ -7,14 +7,10 @@ import GlideCoreDropdown from './dropdown.js';
|
|
7
7
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
8
8
|
it('dispatches one "change" event when an option is selected via click', async () => {
|
9
9
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
10
|
-
<glide-core-dropdown-option
|
11
|
-
label="One"
|
12
|
-
value="one"
|
13
|
-
></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
14
11
|
|
15
12
|
<glide-core-dropdown-option
|
16
13
|
label="Two"
|
17
|
-
value="two"
|
18
14
|
selected
|
19
15
|
></glide-core-dropdown-option>
|
20
16
|
</glide-core-dropdown>`);
|
@@ -30,14 +26,10 @@ it('dispatches one "change" event when an option is selected via click', async (
|
|
30
26
|
});
|
31
27
|
it('dispatches one "change" event when an option is selected via Enter', async () => {
|
32
28
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
33
|
-
<glide-core-dropdown-option
|
34
|
-
label="One"
|
35
|
-
value="one"
|
36
|
-
></glide-core-dropdown-option>
|
29
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
37
30
|
|
38
31
|
<glide-core-dropdown-option
|
39
32
|
label="Two"
|
40
|
-
value="two"
|
41
33
|
selected
|
42
34
|
></glide-core-dropdown-option>
|
43
35
|
</glide-core-dropdown>`);
|
@@ -57,14 +49,10 @@ it('dispatches one "change" event when an option is selected via Enter', async (
|
|
57
49
|
});
|
58
50
|
it('dispatches one "change" event when an option is selected via Space', async () => {
|
59
51
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
60
|
-
<glide-core-dropdown-option
|
61
|
-
label="One"
|
62
|
-
value="one"
|
63
|
-
></glide-core-dropdown-option>
|
52
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
64
53
|
|
65
54
|
<glide-core-dropdown-option
|
66
55
|
label="Two"
|
67
|
-
value="two"
|
68
56
|
selected
|
69
57
|
></glide-core-dropdown-option>
|
70
58
|
</glide-core-dropdown>`);
|
@@ -171,14 +159,10 @@ it('does not dispatch an "edit" event when `readonly`', async () => {
|
|
171
159
|
});
|
172
160
|
it('dispatches one "input" event when an option is selected via click', async () => {
|
173
161
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
174
|
-
<glide-core-dropdown-option
|
175
|
-
label="One"
|
176
|
-
value="one"
|
177
|
-
></glide-core-dropdown-option>
|
162
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
178
163
|
|
179
164
|
<glide-core-dropdown-option
|
180
165
|
label="Two"
|
181
|
-
value="two"
|
182
166
|
selected
|
183
167
|
></glide-core-dropdown-option>
|
184
168
|
</glide-core-dropdown>`);
|
@@ -194,14 +178,10 @@ it('dispatches one "input" event when an option is selected via click', async ()
|
|
194
178
|
});
|
195
179
|
it('dispatches one "input" event when an option is selected via Enter', async () => {
|
196
180
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
197
|
-
<glide-core-dropdown-option
|
198
|
-
label="One"
|
199
|
-
value="one"
|
200
|
-
></glide-core-dropdown-option>
|
181
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
201
182
|
|
202
183
|
<glide-core-dropdown-option
|
203
184
|
label="Two"
|
204
|
-
value="two"
|
205
185
|
selected
|
206
186
|
></glide-core-dropdown-option>
|
207
187
|
</glide-core-dropdown>`);
|
@@ -221,14 +201,10 @@ it('dispatches one "input" event when an option is selected via Enter', async ()
|
|
221
201
|
});
|
222
202
|
it('dispatches one "input" event when an option is selected via Space', async () => {
|
223
203
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
224
|
-
<glide-core-dropdown-option
|
225
|
-
label="One"
|
226
|
-
value="one"
|
227
|
-
></glide-core-dropdown-option>
|
204
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
228
205
|
|
229
206
|
<glide-core-dropdown-option
|
230
207
|
label="Two"
|
231
|
-
value="two"
|
232
208
|
selected
|
233
209
|
></glide-core-dropdown-option>
|
234
210
|
</glide-core-dropdown>`);
|
@@ -267,14 +243,10 @@ it('does not dispatch a "change" event when an already selected option is clicke
|
|
267
243
|
});
|
268
244
|
it('does not dispatch a "change" event when `value` is changed programmatically', async () => {
|
269
245
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
270
|
-
<glide-core-dropdown-option
|
271
|
-
label="One"
|
272
|
-
value="one"
|
273
|
-
></glide-core-dropdown-option>
|
246
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
274
247
|
|
275
248
|
<glide-core-dropdown-option
|
276
249
|
label="Two"
|
277
|
-
value="two"
|
278
250
|
selected
|
279
251
|
></glide-core-dropdown-option>
|
280
252
|
</glide-core-dropdown>`);
|
@@ -288,14 +260,10 @@ it('does not dispatch a "change" event when `value` is changed programmatically'
|
|
288
260
|
});
|
289
261
|
it('continues to dispatch "change" events upon selection after `value` is changed programmatically', async () => {
|
290
262
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
291
|
-
<glide-core-dropdown-option
|
292
|
-
label="One"
|
293
|
-
value="one"
|
294
|
-
></glide-core-dropdown-option>
|
263
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
295
264
|
|
296
265
|
<glide-core-dropdown-option
|
297
266
|
label="Two"
|
298
|
-
value="two"
|
299
267
|
selected
|
300
268
|
></glide-core-dropdown-option>
|
301
269
|
</glide-core-dropdown>`);
|
@@ -308,14 +276,10 @@ it('continues to dispatch "change" events upon selection after `value` is change
|
|
308
276
|
});
|
309
277
|
it('does not dispatch an "input" event when `value` is changed programmatically', async () => {
|
310
278
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
311
|
-
<glide-core-dropdown-option
|
312
|
-
label="One"
|
313
|
-
value="one"
|
314
|
-
></glide-core-dropdown-option>
|
279
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
315
280
|
|
316
281
|
<glide-core-dropdown-option
|
317
282
|
label="Two"
|
318
|
-
value="two"
|
319
283
|
selected
|
320
284
|
></glide-core-dropdown-option>
|
321
285
|
</glide-core-dropdown>`);
|
@@ -331,14 +295,10 @@ it('does not dispatch a "change" event when an already selected option is select
|
|
331
295
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
332
296
|
<glide-core-dropdown-option
|
333
297
|
label="One"
|
334
|
-
value="one"
|
335
298
|
selected
|
336
299
|
></glide-core-dropdown-option>
|
337
300
|
|
338
|
-
<glide-core-dropdown-option
|
339
|
-
label="Two"
|
340
|
-
value="two"
|
341
|
-
></glide-core-dropdown-option>
|
301
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
342
302
|
</glide-core-dropdown>`);
|
343
303
|
const spy = sinon.spy();
|
344
304
|
component.addEventListener('change', spy);
|
@@ -352,14 +312,10 @@ it('does not dispatch an "input" event when an already selected option is select
|
|
352
312
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
353
313
|
<glide-core-dropdown-option
|
354
314
|
label="One"
|
355
|
-
value="one"
|
356
315
|
selected
|
357
316
|
></glide-core-dropdown-option>
|
358
317
|
|
359
|
-
<glide-core-dropdown-option
|
360
|
-
label="Two"
|
361
|
-
value="two"
|
362
|
-
></glide-core-dropdown-option>
|
318
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
363
319
|
</glide-core-dropdown>`);
|
364
320
|
const spy = sinon.spy();
|
365
321
|
component.addEventListener('input', spy);
|
@@ -371,14 +327,10 @@ it('does not dispatch an "input" event when an already selected option is select
|
|
371
327
|
});
|
372
328
|
it('continues to dispatch "input" events upon selection after `value` is changed programmatically', async () => {
|
373
329
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" open>
|
374
|
-
<glide-core-dropdown-option
|
375
|
-
label="One"
|
376
|
-
value="one"
|
377
|
-
></glide-core-dropdown-option>
|
330
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
378
331
|
|
379
332
|
<glide-core-dropdown-option
|
380
333
|
label="Two"
|
381
|
-
value="two"
|
382
334
|
selected
|
383
335
|
></glide-core-dropdown-option>
|
384
336
|
</glide-core-dropdown>`);
|
@@ -7,60 +7,17 @@ import GlideCoreDropdownOption from './dropdown.option.js';
|
|
7
7
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
8
8
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
9
9
|
const defaultSlot = html `
|
10
|
-
<glide-core-dropdown-option
|
11
|
-
|
12
|
-
|
13
|
-
></glide-core-dropdown-option>
|
14
|
-
|
15
|
-
<glide-core-dropdown-option
|
16
|
-
|
17
|
-
|
18
|
-
></glide-core-dropdown-option>
|
19
|
-
|
20
|
-
<glide-core-dropdown-option
|
21
|
-
label="Three"
|
22
|
-
value="three"
|
23
|
-
></glide-core-dropdown-option>
|
24
|
-
|
25
|
-
<glide-core-dropdown-option
|
26
|
-
label="Four"
|
27
|
-
value="four"
|
28
|
-
></glide-core-dropdown-option>
|
29
|
-
|
30
|
-
<glide-core-dropdown-option
|
31
|
-
label="Five"
|
32
|
-
value="five"
|
33
|
-
></glide-core-dropdown-option>
|
34
|
-
|
35
|
-
<glide-core-dropdown-option
|
36
|
-
label="Six"
|
37
|
-
value="six"
|
38
|
-
></glide-core-dropdown-option>
|
39
|
-
|
40
|
-
<glide-core-dropdown-option
|
41
|
-
label="Seven"
|
42
|
-
value="seven"
|
43
|
-
></glide-core-dropdown-option>
|
44
|
-
|
45
|
-
<glide-core-dropdown-option
|
46
|
-
label="Eight"
|
47
|
-
value="eight"
|
48
|
-
></glide-core-dropdown-option>
|
49
|
-
|
50
|
-
<glide-core-dropdown-option
|
51
|
-
label="Nine"
|
52
|
-
value="nine"
|
53
|
-
></glide-core-dropdown-option>
|
54
|
-
|
55
|
-
<glide-core-dropdown-option
|
56
|
-
label="Ten"
|
57
|
-
value="ten"
|
58
|
-
></glide-core-dropdown-option>
|
59
|
-
|
60
|
-
<glide-core-dropdown-option
|
61
|
-
label="Eleven"
|
62
|
-
value="eleven"
|
63
|
-
></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
11
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
12
|
+
<glide-core-dropdown-option label="Three"></glide-core-dropdown-option>
|
13
|
+
<glide-core-dropdown-option label="Four"></glide-core-dropdown-option>
|
14
|
+
<glide-core-dropdown-option label="Five"></glide-core-dropdown-option>
|
15
|
+
<glide-core-dropdown-option label="Six"></glide-core-dropdown-option>
|
16
|
+
<glide-core-dropdown-option label="Seven"></glide-core-dropdown-option>
|
17
|
+
<glide-core-dropdown-option label="Eight"></glide-core-dropdown-option>
|
18
|
+
<glide-core-dropdown-option label="Nine"></glide-core-dropdown-option>
|
19
|
+
<glide-core-dropdown-option label="Ten"></glide-core-dropdown-option>
|
20
|
+
<glide-core-dropdown-option label="Eleven"></glide-core-dropdown-option>
|
64
21
|
`;
|
65
22
|
it('focuses the input when `focus()` is called', async () => {
|
66
23
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
@@ -130,10 +87,6 @@ it('focuses the input on submit when required and no option is selected', async
|
|
130
87
|
const form = document.createElement('form');
|
131
88
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
132
89
|
${defaultSlot}
|
133
|
-
<glide-core-dropdown-option
|
134
|
-
label="Label"
|
135
|
-
value="value"
|
136
|
-
></glide-core-dropdown-option>
|
137
90
|
</glide-core-dropdown>`, {
|
138
91
|
parentNode: form,
|
139
92
|
});
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
2
|
import './dropdown.option.js';
|
3
|
-
import { expect, fixture, html } from '@open-wc/testing';
|
3
|
+
import { aTimeout, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
|
4
4
|
import { sendKeys } from '@web/test-runner-commands';
|
5
5
|
import GlideCoreDropdown from './dropdown.js';
|
6
6
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
@@ -14,10 +14,7 @@ it('closes and reports validity when it loses focus', async () => {
|
|
14
14
|
open
|
15
15
|
required
|
16
16
|
>
|
17
|
-
<glide-core-dropdown-option
|
18
|
-
label="Label"
|
19
|
-
value="value"
|
20
|
-
></glide-core-dropdown-option>
|
17
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
21
18
|
</glide-core-dropdown>`, { parentNode: div });
|
22
19
|
const button = document.createElement('button');
|
23
20
|
div.prepend(button);
|
@@ -39,10 +36,7 @@ it('closes and reports validity when it loses focus', async () => {
|
|
39
36
|
});
|
40
37
|
it('is focused when clicked', async () => {
|
41
38
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
42
|
-
<glide-core-dropdown-option
|
43
|
-
label="Label"
|
44
|
-
value="value"
|
45
|
-
></glide-core-dropdown-option>
|
39
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
46
40
|
</glide-core-dropdown>`);
|
47
41
|
// Calling `click()` would be sweet. The problem is it sets `event.detail` to `0`,
|
48
42
|
// which puts us in a guard in the event handler. `Event` has no `detail` property
|
@@ -52,3 +46,62 @@ it('is focused when clicked', async () => {
|
|
52
46
|
button?.dispatchEvent(new CustomEvent('click', { bubbles: true, detail: 1 }));
|
53
47
|
expect(component.shadowRoot?.activeElement).to.equal(button);
|
54
48
|
});
|
49
|
+
it('focuses the Add button on ArrowDown', async () => {
|
50
|
+
const component = await fixture(html `<glide-core-dropdown
|
51
|
+
add-button-label="Add"
|
52
|
+
label="Label"
|
53
|
+
placeholder="Placeholder"
|
54
|
+
open
|
55
|
+
>
|
56
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
57
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
58
|
+
</glide-core-dropdown>`);
|
59
|
+
// Wait for it to open.
|
60
|
+
await aTimeout(0);
|
61
|
+
const options = component.querySelectorAll('glide-core-dropdown-option');
|
62
|
+
component.focus();
|
63
|
+
await sendKeys({ press: 'ArrowDown' }); // Two
|
64
|
+
await sendKeys({ press: 'ArrowDown' }); // Add button
|
65
|
+
const addButton = component.shadowRoot?.querySelector('[data-test="add-button"]');
|
66
|
+
expect(options[0]?.privateActive).to.be.false;
|
67
|
+
expect(options[0]?.privateActive).to.be.false;
|
68
|
+
expect(options[1]?.privateActive).to.be.false;
|
69
|
+
expect(options[1]?.privateIsEditActive).to.be.false;
|
70
|
+
expect(options[1]?.privateIsOpenTooltip).to.be.false;
|
71
|
+
expect(component.shadowRoot?.activeElement).to.equal(addButton);
|
72
|
+
});
|
73
|
+
it('returns focus to itself on Escape when the Add button has focus', async () => {
|
74
|
+
const component = await fixture(html `<glide-core-dropdown
|
75
|
+
add-button-label="Add"
|
76
|
+
label="Label"
|
77
|
+
placeholder="Placeholder"
|
78
|
+
open
|
79
|
+
>
|
80
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
81
|
+
</glide-core-dropdown>`);
|
82
|
+
// Wait for it to open.
|
83
|
+
await aTimeout(0);
|
84
|
+
component.focus();
|
85
|
+
await sendKeys({ press: 'Tab' });
|
86
|
+
await sendKeys({ press: 'Escape' });
|
87
|
+
expect(document.activeElement).to.equal(component);
|
88
|
+
});
|
89
|
+
it('returns focus to itself when an option is activated and the Add button has focus', async () => {
|
90
|
+
const component = await fixture(html `<glide-core-dropdown
|
91
|
+
add-button-label="Add"
|
92
|
+
label="Label"
|
93
|
+
placeholder="Placeholder"
|
94
|
+
open
|
95
|
+
>
|
96
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
97
|
+
</glide-core-dropdown>`);
|
98
|
+
// Wait for it to open.
|
99
|
+
await aTimeout(0);
|
100
|
+
component.focus();
|
101
|
+
await sendKeys({ press: 'Tab' });
|
102
|
+
component
|
103
|
+
.querySelector('glide-core-dropdown-option')
|
104
|
+
?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
105
|
+
await elementUpdated(component);
|
106
|
+
expect(document.activeElement).to.equal(component);
|
107
|
+
});
|
@@ -6,15 +6,8 @@ GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
|
6
6
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
7
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
13
|
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="primary-button"]'));
|
@@ -27,15 +20,9 @@ it('focuses the primary button on submit when required and no options are select
|
|
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
|
});
|
@@ -51,15 +38,8 @@ it('focuses the primary button when `reportValidity` is called when required and
|
|
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
45
|
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
@@ -75,13 +55,11 @@ it('does not focus the primary 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,19 +75,16 @@ 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>`);
|
@@ -129,19 +104,16 @@ it('focuses the third tag when the second one is removed', async () => {
|
|
129
104
|
>
|
130
105
|
<glide-core-dropdown-option
|
131
106
|
label="One"
|
132
|
-
value="one"
|
133
107
|
selected
|
134
108
|
></glide-core-dropdown-option>
|
135
109
|
|
136
110
|
<glide-core-dropdown-option
|
137
111
|
label="Two"
|
138
|
-
value="two"
|
139
112
|
selected
|
140
113
|
></glide-core-dropdown-option>
|
141
114
|
|
142
115
|
<glide-core-dropdown-option
|
143
116
|
label="Three"
|
144
|
-
value="three"
|
145
117
|
selected
|
146
118
|
></glide-core-dropdown-option>
|
147
119
|
</glide-core-dropdown>`);
|
@@ -152,7 +124,7 @@ it('focuses the third tag when the second one is removed', async () => {
|
|
152
124
|
await aTimeout(0);
|
153
125
|
expect(component.shadowRoot?.activeElement).to.equal(tags?.[2]);
|
154
126
|
});
|
155
|
-
it('focuses the second tag when the
|
127
|
+
it('focuses the second tag when the third tag removed', async () => {
|
156
128
|
const component = await fixture(html `<glide-core-dropdown
|
157
129
|
label="Label"
|
158
130
|
placeholder="Placeholder"
|
@@ -161,19 +133,16 @@ it('focuses the second tag when the last one removed', async () => {
|
|
161
133
|
>
|
162
134
|
<glide-core-dropdown-option
|
163
135
|
label="One"
|
164
|
-
value="one"
|
165
136
|
selected
|
166
137
|
></glide-core-dropdown-option>
|
167
138
|
|
168
139
|
<glide-core-dropdown-option
|
169
140
|
label="Two"
|
170
|
-
value="two"
|
171
141
|
selected
|
172
142
|
></glide-core-dropdown-option>
|
173
143
|
|
174
144
|
<glide-core-dropdown-option
|
175
145
|
label="Three"
|
176
|
-
value="three"
|
177
146
|
selected
|
178
147
|
></glide-core-dropdown-option>
|
179
148
|
</glide-core-dropdown>`);
|
@@ -184,3 +153,18 @@ it('focuses the second tag when the last one removed', async () => {
|
|
184
153
|
await aTimeout(0);
|
185
154
|
expect(component.shadowRoot?.activeElement).to.equal(tags?.[1]);
|
186
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,15 +1,13 @@
|
|
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
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
13
|
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="primary-button"]'));
|
@@ -17,10 +15,7 @@ it('focuses the primary button when `focus()` is called', async () => {
|
|
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
|
});
|
@@ -31,10 +26,7 @@ it('focuses the button on submit', async () => {
|
|
31
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
32
|
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
@@ -43,11 +35,24 @@ it('focuses the primary button when `reportValidity` is called when required and
|
|
43
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
|
+
});
|