@gitlab/ui 64.10.0 → 64.10.1
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [64.10.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.10.0...v64.10.1) (2023-06-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **GlCollapsibleListbox:** listbox stays open ([a83355d](https://gitlab.com/gitlab-org/gitlab-ui/commit/a83355d527c483ca6bd6587da64f565ef118b8da))
|
|
7
|
+
|
|
1
8
|
# [64.10.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.9.0...v64.10.0) (2023-06-14)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -329,7 +329,7 @@ var script = {
|
|
|
329
329
|
},
|
|
330
330
|
computed: {
|
|
331
331
|
listboxTag() {
|
|
332
|
-
if (this.
|
|
332
|
+
if (!this.hasItems || isOption(this.items[0])) return 'ul';
|
|
333
333
|
return 'div';
|
|
334
334
|
},
|
|
335
335
|
listboxClasses() {
|
|
@@ -345,6 +345,9 @@ var script = {
|
|
|
345
345
|
flattenedOptions() {
|
|
346
346
|
return flattenedOptions(this.items);
|
|
347
347
|
},
|
|
348
|
+
hasItems() {
|
|
349
|
+
return this.items.length > 0;
|
|
350
|
+
},
|
|
348
351
|
listboxToggleText() {
|
|
349
352
|
if (!this.toggleText) {
|
|
350
353
|
if (!this.multiple && this.selectedValues.length) {
|
|
@@ -384,6 +387,17 @@ var script = {
|
|
|
384
387
|
if (!this.resetButtonLabel) {
|
|
385
388
|
return false;
|
|
386
389
|
}
|
|
390
|
+
if (!this.multiple) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* if dropdown has no items
|
|
396
|
+
* reset all should be hidden
|
|
397
|
+
*/
|
|
398
|
+
if (!this.hasItems) {
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
387
401
|
if (this.multiple) {
|
|
388
402
|
return this.selected.length > 0;
|
|
389
403
|
}
|
|
@@ -396,6 +410,14 @@ var script = {
|
|
|
396
410
|
if (!this.multiple) {
|
|
397
411
|
return false;
|
|
398
412
|
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* if dropdown has no items
|
|
416
|
+
* select all should be hidden
|
|
417
|
+
*/
|
|
418
|
+
if (!this.hasItems) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
399
421
|
return this.selected.length === 0;
|
|
400
422
|
},
|
|
401
423
|
showIntersectionObserver() {
|
|
@@ -614,7 +636,6 @@ var script = {
|
|
|
614
636
|
* @event reset
|
|
615
637
|
*/
|
|
616
638
|
this.$emit('reset');
|
|
617
|
-
this.closeAndFocus();
|
|
618
639
|
},
|
|
619
640
|
onSelectAllButtonClicked() {
|
|
620
641
|
/**
|
package/package.json
CHANGED
|
@@ -179,6 +179,15 @@ describe('GlCollapsibleListbox', () => {
|
|
|
179
179
|
await nextTick();
|
|
180
180
|
expect(wrapper.emitted('select')[0][0]).toEqual(mockOptions[2].value);
|
|
181
181
|
});
|
|
182
|
+
|
|
183
|
+
it('close dropdown for single selection', () => {
|
|
184
|
+
jest.spyOn(wrapper.vm, 'closeAndFocus');
|
|
185
|
+
expect(wrapper.vm.closeAndFocus).not.toHaveBeenCalled();
|
|
186
|
+
|
|
187
|
+
findListboxItems().at(2).vm.$emit('select', true);
|
|
188
|
+
|
|
189
|
+
expect(wrapper.vm.closeAndFocus).toHaveBeenCalled();
|
|
190
|
+
});
|
|
182
191
|
});
|
|
183
192
|
|
|
184
193
|
describe('with groups', () => {
|
|
@@ -475,17 +484,47 @@ describe('GlCollapsibleListbox', () => {
|
|
|
475
484
|
expect(wrapper).toHaveLoggedVueErrors();
|
|
476
485
|
});
|
|
477
486
|
|
|
487
|
+
it.each`
|
|
488
|
+
multiple
|
|
489
|
+
${true}
|
|
490
|
+
${false}
|
|
491
|
+
`(
|
|
492
|
+
'shows the reset button if the label is provided and the selection is not empty and mode if multiple mode is $multiple',
|
|
493
|
+
({ multiple }) => {
|
|
494
|
+
buildWrapper({
|
|
495
|
+
headerText: 'Select assignee',
|
|
496
|
+
resetButtonLabel: 'Unassign',
|
|
497
|
+
selected: mockOptions[1].value,
|
|
498
|
+
items: mockOptions,
|
|
499
|
+
multiple,
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
expect(findResetButton().exists()).toBe(multiple);
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
|
|
478
506
|
it('shows the reset button if the label is provided and the selection is not empty', () => {
|
|
479
507
|
buildWrapper({
|
|
480
508
|
headerText: 'Select assignee',
|
|
481
509
|
resetButtonLabel: 'Unassign',
|
|
482
510
|
selected: mockOptions[1].value,
|
|
483
511
|
items: mockOptions,
|
|
512
|
+
multiple: true,
|
|
484
513
|
});
|
|
485
|
-
const button = findResetButton();
|
|
486
514
|
|
|
487
|
-
expect(
|
|
488
|
-
|
|
515
|
+
expect(findResetButton().text()).toBe('Unassign');
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it('hides reset button if dropdown has no items', () => {
|
|
519
|
+
buildWrapper({
|
|
520
|
+
headerText: 'Select assignee',
|
|
521
|
+
resetButtonLabel: 'Unassign',
|
|
522
|
+
selected: mockOptions[1].value,
|
|
523
|
+
items: [],
|
|
524
|
+
multiple: true,
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
expect(findResetButton().exists()).toBe(false);
|
|
489
528
|
});
|
|
490
529
|
|
|
491
530
|
it.each`
|
|
@@ -503,12 +542,13 @@ describe('GlCollapsibleListbox', () => {
|
|
|
503
542
|
expect(findResetButton().exists()).toBe(false);
|
|
504
543
|
});
|
|
505
544
|
|
|
506
|
-
it('on click, emits the reset event and
|
|
545
|
+
it('on click, emits the reset event does not and call closeAndFocus() for multiple mode', () => {
|
|
507
546
|
buildWrapper({
|
|
508
547
|
headerText: 'Select assignee',
|
|
509
548
|
resetButtonLabel: 'Unassign',
|
|
510
549
|
selected: mockOptions[1].value,
|
|
511
550
|
items: mockOptions,
|
|
551
|
+
multiple: true,
|
|
512
552
|
});
|
|
513
553
|
jest.spyOn(wrapper.vm, 'closeAndFocus');
|
|
514
554
|
|
|
@@ -518,7 +558,7 @@ describe('GlCollapsibleListbox', () => {
|
|
|
518
558
|
findResetButton().trigger('click');
|
|
519
559
|
|
|
520
560
|
expect(wrapper.emitted('reset')).toHaveLength(1);
|
|
521
|
-
expect(wrapper.vm.closeAndFocus).toHaveBeenCalled();
|
|
561
|
+
expect(wrapper.vm.closeAndFocus).not.toHaveBeenCalled();
|
|
522
562
|
});
|
|
523
563
|
});
|
|
524
564
|
|
|
@@ -533,12 +573,12 @@ describe('GlCollapsibleListbox', () => {
|
|
|
533
573
|
});
|
|
534
574
|
|
|
535
575
|
it.each`
|
|
536
|
-
multiple |
|
|
537
|
-
${false} | ${false}
|
|
538
|
-
${true} | ${true}
|
|
576
|
+
multiple | resetVisible | selectAllVisible
|
|
577
|
+
${false} | ${false} | ${false}
|
|
578
|
+
${true} | ${false} | ${true}
|
|
539
579
|
`(
|
|
540
580
|
'shows the select all button if the label is provided and the selection is empty and multiple option is $multiple',
|
|
541
|
-
({ multiple,
|
|
581
|
+
({ multiple, resetVisible, selectAllVisible }) => {
|
|
542
582
|
buildWrapper({
|
|
543
583
|
headerText: 'Select assignee',
|
|
544
584
|
resetButtonLabel: 'Unassign',
|
|
@@ -548,11 +588,23 @@ describe('GlCollapsibleListbox', () => {
|
|
|
548
588
|
multiple,
|
|
549
589
|
});
|
|
550
590
|
|
|
551
|
-
expect(findResetButton().exists()).toBe(
|
|
552
|
-
expect(findSelectAllButton().exists()).toBe(
|
|
591
|
+
expect(findResetButton().exists()).toBe(resetVisible);
|
|
592
|
+
expect(findSelectAllButton().exists()).toBe(selectAllVisible);
|
|
553
593
|
}
|
|
554
594
|
);
|
|
555
595
|
|
|
596
|
+
it('hides select all button if dropdown has no items', () => {
|
|
597
|
+
buildWrapper({
|
|
598
|
+
headerText: 'Select assignee',
|
|
599
|
+
resetButtonLabel: 'Unassign',
|
|
600
|
+
showSelectAllButtonLabel: 'Select All',
|
|
601
|
+
items: [],
|
|
602
|
+
multiple: true,
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
expect(findSelectAllButton().exists()).toBe(false);
|
|
606
|
+
});
|
|
607
|
+
|
|
556
608
|
it('has the label text "Select All" if the label is provided and the selection is empty', () => {
|
|
557
609
|
buildWrapper({
|
|
558
610
|
headerText: 'Select assignee',
|
|
@@ -345,7 +345,7 @@ export default {
|
|
|
345
345
|
},
|
|
346
346
|
computed: {
|
|
347
347
|
listboxTag() {
|
|
348
|
-
if (this.
|
|
348
|
+
if (!this.hasItems || isOption(this.items[0])) return 'ul';
|
|
349
349
|
return 'div';
|
|
350
350
|
},
|
|
351
351
|
listboxClasses() {
|
|
@@ -361,6 +361,9 @@ export default {
|
|
|
361
361
|
flattenedOptions() {
|
|
362
362
|
return flattenedOptions(this.items);
|
|
363
363
|
},
|
|
364
|
+
hasItems() {
|
|
365
|
+
return this.items.length > 0;
|
|
366
|
+
},
|
|
364
367
|
listboxToggleText() {
|
|
365
368
|
if (!this.toggleText) {
|
|
366
369
|
if (!this.multiple && this.selectedValues.length) {
|
|
@@ -394,6 +397,19 @@ export default {
|
|
|
394
397
|
if (!this.resetButtonLabel) {
|
|
395
398
|
return false;
|
|
396
399
|
}
|
|
400
|
+
|
|
401
|
+
if (!this.multiple) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* if dropdown has no items
|
|
407
|
+
* reset all should be hidden
|
|
408
|
+
*/
|
|
409
|
+
if (!this.hasItems) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
|
|
397
413
|
if (this.multiple) {
|
|
398
414
|
return this.selected.length > 0;
|
|
399
415
|
}
|
|
@@ -408,6 +424,14 @@ export default {
|
|
|
408
424
|
return false;
|
|
409
425
|
}
|
|
410
426
|
|
|
427
|
+
/**
|
|
428
|
+
* if dropdown has no items
|
|
429
|
+
* select all should be hidden
|
|
430
|
+
*/
|
|
431
|
+
if (!this.hasItems) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
|
|
411
435
|
return this.selected.length === 0;
|
|
412
436
|
},
|
|
413
437
|
showIntersectionObserver() {
|
|
@@ -636,7 +660,6 @@ export default {
|
|
|
636
660
|
* @event reset
|
|
637
661
|
*/
|
|
638
662
|
this.$emit('reset');
|
|
639
|
-
this.closeAndFocus();
|
|
640
663
|
},
|
|
641
664
|
onSelectAllButtonClicked() {
|
|
642
665
|
/**
|