@gitlab/ui 129.1.2 → 129.2.0

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.
@@ -1,4 +1,4 @@
1
- import { uniqueId, clamp } from 'lodash-es';
1
+ import { uniqueId, isEqual, clamp } from 'lodash-es';
2
2
  import { logWarning, stopEvent } from '../../../../utils/utils';
3
3
  import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_FOCUS_CONTENT, POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, ENTER, ARROW_DOWN, ARROW_UP, END, HOME } from '../constants';
4
4
  import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
@@ -548,7 +548,7 @@ var script = {
548
548
  watch: {
549
549
  selected: {
550
550
  immediate: true,
551
- handler(newSelected) {
551
+ handler(newSelected, oldSelected) {
552
552
  if (Array.isArray(newSelected)) {
553
553
  if (process.env.NODE_ENV !== 'production' && !this.multiple && newSelected.length) {
554
554
  throw new Error('To allow multi-selection, please, set "multiple" property to "true"');
@@ -557,6 +557,16 @@ var script = {
557
557
  } else {
558
558
  this.selectedValues = [newSelected];
559
559
  }
560
+ if (
561
+ // Do not emit change event immediately on watcher creation.
562
+ oldSelected !== undefined && !isEqual(newSelected, oldSelected)) {
563
+ /**
564
+ * Emitted when the selected prop value changes
565
+ *
566
+ * @event change
567
+ */
568
+ this.$emit('change');
569
+ }
560
570
  }
561
571
  },
562
572
  items: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "129.1.2",
3
+ "version": "129.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -139,10 +139,10 @@
139
139
  "gitlab-api-async-iterator": "^1.3.1",
140
140
  "glob": "11.1.0",
141
141
  "identity-obj-proxy": "^3.0.0",
142
- "jest": "30.2.0",
143
- "jest-circus": "30.2.0",
144
- "jest-environment-jsdom": "30.2.0",
145
- "jest-image-snapshot": "^6.5.1",
142
+ "jest": "30.3.0",
143
+ "jest-circus": "30.3.0",
144
+ "jest-environment-jsdom": "30.3.0",
145
+ "jest-image-snapshot": "^6.5.2",
146
146
  "merge-cobertura": "^1.0.7",
147
147
  "mockdate": "^3.0.5",
148
148
  "module-alias": "^2.3.4",
@@ -160,7 +160,7 @@
160
160
  "rollup-plugin-string": "^3.0.0",
161
161
  "rollup-plugin-svg": "^2.0.0",
162
162
  "rollup-plugin-vue": "^5.1.9",
163
- "sass": "^1.97.3",
163
+ "sass": "^1.98.0",
164
164
  "sass-loader": "^10.5.2",
165
165
  "sass-true": "^9",
166
166
  "start-server-and-test": "^2.1.5",
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { clamp, uniqueId } from 'lodash-es';
2
+ import { clamp, uniqueId, isEqual } from 'lodash-es';
3
3
  import { stopEvent, logWarning } from '../../../../utils/utils';
4
4
  import {
5
5
  GL_DROPDOWN_SHOWN,
@@ -582,7 +582,7 @@ export default {
582
582
  watch: {
583
583
  selected: {
584
584
  immediate: true,
585
- handler(newSelected) {
585
+ handler(newSelected, oldSelected) {
586
586
  if (Array.isArray(newSelected)) {
587
587
  if (process.env.NODE_ENV !== 'production' && !this.multiple && newSelected.length) {
588
588
  throw new Error('To allow multi-selection, please, set "multiple" property to "true"');
@@ -591,6 +591,19 @@ export default {
591
591
  } else {
592
592
  this.selectedValues = [newSelected];
593
593
  }
594
+
595
+ if (
596
+ // Do not emit change event immediately on watcher creation.
597
+ oldSelected !== undefined &&
598
+ !isEqual(newSelected, oldSelected)
599
+ ) {
600
+ /**
601
+ * Emitted when the selected prop value changes
602
+ *
603
+ * @event change
604
+ */
605
+ this.$emit('change');
606
+ }
594
607
  },
595
608
  },
596
609
  items: {