@gitlab/ui 64.18.0 → 64.18.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.18.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.18.0...v64.18.1) (2023-07-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **listbox:** Allow use of reset button on single select ([cff7777](https://gitlab.com/gitlab-org/gitlab-ui/commit/cff7777e5eff36de54d4f628f818fc44284d1de1))
7
+
1
8
  # [64.18.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.17.0...v64.18.0) (2023-07-04)
2
9
 
3
10
 
@@ -387,9 +387,6 @@ var script = {
387
387
  if (!this.resetButtonLabel) {
388
388
  return false;
389
389
  }
390
- if (!this.multiple) {
391
- return false;
392
- }
393
390
 
394
391
  /**
395
392
  * if dropdown has no items
@@ -398,6 +395,13 @@ var script = {
398
395
  if (!this.hasItems) {
399
396
  return false;
400
397
  }
398
+
399
+ /**
400
+ * hide if no selection
401
+ */
402
+ if (this.selected.length === 0) {
403
+ return false;
404
+ }
401
405
  if (this.multiple) {
402
406
  return this.selected.length === this.items.length;
403
407
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 04 Jul 2023 11:29:36 GMT
3
+ * Generated on Tue, 04 Jul 2023 13:02:13 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 04 Jul 2023 11:29:36 GMT
3
+ * Generated on Tue, 04 Jul 2023 13:02:13 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 04 Jul 2023 11:29:36 GMT
3
+ * Generated on Tue, 04 Jul 2023 13:02:13 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#fff";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 04 Jul 2023 11:29:36 GMT
3
+ * Generated on Tue, 04 Jul 2023 13:02:13 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#000";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Tue, 04 Jul 2023 11:29:36 GMT
3
+ // Generated on Tue, 04 Jul 2023 13:02:13 GMT
4
4
 
5
5
  $red-950: #fff4f3;
6
6
  $red-900: #fcf1ef;
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Tue, 04 Jul 2023 11:29:36 GMT
3
+ // Generated on Tue, 04 Jul 2023 13:02:13 GMT
4
4
 
5
5
  $brand-gray-05: #2b2838 !default;
6
6
  $brand-gray-04: #45424d !default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "64.18.0",
3
+ "version": "64.18.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -485,31 +485,33 @@ describe('GlCollapsibleListbox', () => {
485
485
  });
486
486
 
487
487
  it.each`
488
- title | multiple | selected
489
- ${'shows'} | ${true} | ${mockOptionsValues}
490
- ${'hides'} | ${false} | ${mockOptions[1].value}
488
+ description | props
489
+ ${'multi-select'} | ${{ multiple: true, selected: mockOptionsValues }}
490
+ ${'single-select'} | ${{ multiple: false, selected: mockOptions[1].value }}
491
491
  `(
492
- '$title the reset button if the label is provided and the selection is complete and mode if multiple mode is $multiple',
493
- ({ multiple, selected }) => {
492
+ 'shows the button if the label is provided and the selection is complete in $description mode',
493
+ ({ props }) => {
494
494
  buildWrapper({
495
495
  headerText: 'Select assignee',
496
496
  resetButtonLabel: 'Unassign',
497
- selected,
498
497
  items: mockOptions,
499
- multiple,
498
+ ...props,
500
499
  });
501
500
 
502
- expect(findResetButton().exists()).toBe(multiple);
501
+ expect(findResetButton().exists()).toBe(true);
503
502
  }
504
503
  );
505
504
 
506
- it('hides reset button if the label is provided and the selection is not complete', () => {
505
+ it.each`
506
+ description | props
507
+ ${'multi-select'} | ${{ multiple: true, selected: [] }}
508
+ ${'single-select'} | ${{ multiple: false, selected: [] }}
509
+ `('hides the button if the selection is empty in $description mode', ({ props }) => {
507
510
  buildWrapper({
508
511
  headerText: 'Select assignee',
509
512
  resetButtonLabel: 'Unassign',
510
- selected: mockOptions[1].value,
511
513
  items: mockOptions,
512
- multiple: true,
514
+ ...props,
513
515
  });
514
516
 
515
517
  expect(findResetButton().exists()).toBe(false);
@@ -527,22 +529,7 @@ describe('GlCollapsibleListbox', () => {
527
529
  expect(findResetButton().exists()).toBe(false);
528
530
  });
529
531
 
530
- it.each`
531
- description | props
532
- ${'multi-select'} | ${{ multiple: true, selected: [] }}
533
- ${'single-select'} | ${{ multiple: false, selected: null }}
534
- `('hides the button if the selection is empty in $description mode', ({ props }) => {
535
- buildWrapper({
536
- headerText: 'Select assignee',
537
- resetButtonLabel: 'Unassign',
538
- items: mockOptions,
539
- ...props,
540
- });
541
-
542
- expect(findResetButton().exists()).toBe(false);
543
- });
544
-
545
- it('on click, emits the reset event does not and call closeAndFocus() for multiple mode', () => {
532
+ it('on click, emits the `reset` event but does not call `closeAndFocus`', () => {
546
533
  buildWrapper({
547
534
  headerText: 'Select assignee',
548
535
  resetButtonLabel: 'Unassign',
@@ -572,24 +559,31 @@ describe('GlCollapsibleListbox', () => {
572
559
  expect(wrapper).toHaveLoggedVueErrors();
573
560
  });
574
561
 
575
- it.each`
576
- multiple | resetVisible | selectAllVisible
577
- ${false} | ${false} | ${false}
578
- ${true} | ${false} | ${true}
562
+ describe.each`
563
+ multiple | resetVisible | selectAllVisible | selected
564
+ ${false} | ${false} | ${false} | ${[]}
565
+ ${true} | ${false} | ${true} | ${[]}
579
566
  `(
580
- 'shows the select all button if the label is provided and the selection is empty and multiple option is $multiple',
581
- ({ multiple, resetVisible, selectAllVisible }) => {
582
- buildWrapper({
583
- headerText: 'Select assignee',
584
- resetButtonLabel: 'Unassign',
585
- showSelectAllButtonLabel: 'Select All',
586
- selected: [],
587
- items: mockOptions,
588
- multiple,
567
+ 'when label is provided, selection is empty and multiple option is $multiple',
568
+ ({ multiple, resetVisible, selectAllVisible, selected }) => {
569
+ beforeEach(() => {
570
+ buildWrapper({
571
+ headerText: 'Select assignee',
572
+ resetButtonLabel: 'Unassign',
573
+ showSelectAllButtonLabel: 'Select All',
574
+ items: mockOptions,
575
+ selected,
576
+ multiple,
577
+ });
578
+ });
579
+
580
+ it(`${selectAllVisible ? 'shows' : 'does not show'} the Select all button`, () => {
581
+ expect(findSelectAllButton().exists()).toBe(selectAllVisible);
589
582
  });
590
583
 
591
- expect(findResetButton().exists()).toBe(resetVisible);
592
- expect(findSelectAllButton().exists()).toBe(selectAllVisible);
584
+ it(`${resetVisible ? 'shows' : 'does not show'} the Reset button`, () => {
585
+ expect(findResetButton().exists()).toBe(resetVisible);
586
+ });
593
587
  }
594
588
  );
595
589
 
@@ -644,7 +638,7 @@ describe('GlCollapsibleListbox', () => {
644
638
  expect(findSelectAllButton().text()).toBe('Select All');
645
639
  });
646
640
 
647
- it('on click, emits the select-all event and calls closeAndFocus()', () => {
641
+ it('on click, emits the `select-all` event and calls `closeAndFocus`', () => {
648
642
  buildWrapper({
649
643
  headerText: 'Select assignee',
650
644
  resetButtonLabel: 'Unassign',
@@ -398,10 +398,6 @@ export default {
398
398
  return false;
399
399
  }
400
400
 
401
- if (!this.multiple) {
402
- return false;
403
- }
404
-
405
401
  /**
406
402
  * if dropdown has no items
407
403
  * reset all should be hidden
@@ -410,6 +406,13 @@ export default {
410
406
  return false;
411
407
  }
412
408
 
409
+ /**
410
+ * hide if no selection
411
+ */
412
+ if (this.selected.length === 0) {
413
+ return false;
414
+ }
415
+
413
416
  if (this.multiple) {
414
417
  return this.selected.length === this.items.length;
415
418
  }