@gitlab/ui 137.2.5 → 137.2.6

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.
@@ -215,7 +215,7 @@ var script = {
215
215
  const __vue_script__ = script;
216
216
 
217
217
  /* template */
218
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"dropdown b-dropdown gl-dropdown gl-relative",class:{ show: _vm.show }},[_c('ul',{ref:"dropdownMenu",staticClass:"dropdown-menu gl-absolute",class:[{ show: _vm.show }, _vm.menuClass],attrs:{"id":_vm.componentId,"role":"listbox"}},[(_vm.loading)?_c('gl-dropdown-item',{attrs:{"role":"option","disabled":""}},[_vm._t("loading-content",function(){return [_vm._v("Searching...")]})],2):_vm._e(),_vm._v(" "),_vm._l((_vm.dropdownItems),function(dropdownItem){return _c('gl-dropdown-item',{key:dropdownItem.id,ref:"dropdownItems",refInFor:true,attrs:{"id":_vm.dropdownItemIdAttribute(dropdownItem),"data-dropdown-item-id":dropdownItem.id,"active":_vm.dropdownItemIsFocused(dropdownItem),"aria-selected":_vm.dropdownItemIsFocused(dropdownItem).toString(),"active-class":"is-focused","role":"option","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(dropdownItem)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(dropdownItem)}}},[_vm._t("dropdown-item-content",function(){return [_vm._v("\n "+_vm._s(dropdownItem.name)+"\n ")]},{"dropdownItem":dropdownItem})],2)])}),_vm._v(" "),(_vm.userDefinedTokenCanBeAdded)?_c('gl-dropdown-item',{ref:_vm.userDefinedToken.id,attrs:{"id":_vm.dropdownItemIdAttribute(_vm.userDefinedToken),"data-dropdown-item-id":_vm.userDefinedToken.id,"active":_vm.dropdownItemIsFocused(_vm.userDefinedToken),"active-class":"is-focused","role":"option","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(_vm.userDefinedToken)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(_vm.userDefinedToken)}}},[_vm._t("user-defined-token-content",function(){return [_vm._v("\n Add \""+_vm._s(_vm.inputText)+"\"\n ")]},{"inputText":_vm.inputText})],2)]):(!_vm.dropdownItems.length)?_c('gl-dropdown-item',{attrs:{"role":"option","disabled":""}},[_vm._t("no-results-content",function(){return [_vm._v("No matches found")]})],2):_vm._e(),_vm._v(" "),_vm._t("dropdown-footer")],2)])};
218
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"dropdown b-dropdown gl-dropdown gl-relative",class:{ show: _vm.show }},[_c('ul',{ref:"dropdownMenu",staticClass:"dropdown-menu gl-absolute",class:[{ show: _vm.show }, _vm.menuClass],attrs:{"id":_vm.componentId,"role":"listbox"}},[(_vm.loading)?_c('gl-dropdown-item',{attrs:{"role":"option","disabled":""}},[_vm._t("loading-content",function(){return [_vm._v("Searching...")]})],2):_vm._e(),_vm._v(" "),_vm._l((_vm.dropdownItems),function(dropdownItem){return _c('gl-dropdown-item',{key:dropdownItem.id,ref:"dropdownItems",refInFor:true,attrs:{"id":_vm.dropdownItemIdAttribute(dropdownItem),"data-dropdown-item-id":dropdownItem.id,"active":_vm.dropdownItemIsFocused(dropdownItem),"aria-selected":_vm.dropdownItemIsFocused(dropdownItem).toString(),"active-class":"is-focused","role":"option","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(dropdownItem)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(dropdownItem)}}},[_vm._t("dropdown-item-content",function(){return [_vm._v("\n "+_vm._s(dropdownItem.name)+"\n ")]},{"dropdownItem":dropdownItem})],2)])}),_vm._v(" "),(_vm.userDefinedTokenCanBeAdded)?_c('gl-dropdown-item',{ref:_vm.userDefinedToken.id,attrs:{"id":_vm.dropdownItemIdAttribute(_vm.userDefinedToken),"data-dropdown-item-id":_vm.userDefinedToken.id,"active":_vm.dropdownItemIsFocused(_vm.userDefinedToken),"active-class":"is-focused","role":"option","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(_vm.userDefinedToken)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(_vm.userDefinedToken)}}},[_vm._t("user-defined-token-content",function(){return [_vm._v("\n Add \""+_vm._s(_vm.inputText)+"\"\n ")]},{"inputText":_vm.inputText})],2)]):(!_vm.dropdownItems.length && !_vm.loading)?_c('gl-dropdown-item',{attrs:{"role":"option","disabled":""}},[_vm._t("no-results-content",function(){return [_vm._v("No matches found")]})],2):_vm._e(),_vm._v(" "),_vm._t("dropdown-footer")],2)])};
219
219
  var __vue_staticRenderFns__ = [];
220
220
 
221
221
  /* style */
@@ -65,19 +65,16 @@ const onMouseup = () => {
65
65
  const mousedown = 'mousedown';
66
66
  const mouseup = 'mouseup';
67
67
  const startListening = eventTypes => {
68
+ // Listening to mouse events ensures that a text selection doesn't trigger the
69
+ // GlOutsideDirective 'click' callback if the selection started within the target element,
70
+ // and that a Safari focus-loss 'focusin' doesn't trigger the callback either. Nothing is
71
+ // listening yet when the set is empty, so this is bound exactly once.
72
+ if (activeEventTypes.size === 0) {
73
+ document.addEventListener(mousedown, onMousedown);
74
+ document.addEventListener(mouseup, onMouseup);
75
+ }
68
76
  eventTypes.forEach(eventType => {
69
77
  if (!activeEventTypes.has(eventType)) {
70
- // Listening to mousedown events, ensures that a text selection doesn't trigger the
71
- // GlOutsideDirective 'click' callback if the selection started within the target element,
72
- // and that a Safari focus-loss 'focusin' doesn't trigger the callback either. Tracked via
73
- // activeEventTypes too, so it's only ever bound/unbound once, regardless of whether 'click'
74
- // and 'focusin' are (de)activated together or separately.
75
- if ((eventType === click || eventType === focusin) && !activeEventTypes.has(mousedown)) {
76
- document.addEventListener(mousedown, onMousedown);
77
- document.addEventListener(mouseup, onMouseup);
78
- activeEventTypes.add(mousedown);
79
- }
80
-
81
78
  // Added { capture: true } to all event types to prevent the behavior discussed in https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/1686#note_412545027
82
79
  // Ensures the event listener handles the event in the capturing phase, avoiding issues encountered previously.
83
80
  // Cannot be tested with Jest or Cypress, but can be tested with Playwright in the future: https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/4272#note_1947425384
@@ -97,17 +94,18 @@ const stopListening = eventTypesToUnbind => {
97
94
  let eventTypes = _ref2.eventTypes;
98
95
  return !eventTypes.includes(eventType);
99
96
  })) {
100
- document.removeEventListener(eventType, globalListener);
97
+ document.removeEventListener(eventType, globalListener, {
98
+ capture: true
99
+ });
101
100
  activeEventTypes.delete(eventType);
102
101
  }
103
102
  }
104
103
  });
105
104
 
106
- // Only unbind mousedown once neither 'click' nor 'focusin' need it anymore.
107
- if (activeEventTypes.has(mousedown) && !activeEventTypes.has(click) && !activeEventTypes.has(focusin)) {
105
+ // Nothing is listening anymore, so the mouse gesture tracking isn't needed either.
106
+ if (activeEventTypes.size === 0) {
108
107
  document.removeEventListener(mousedown, onMousedown);
109
108
  document.removeEventListener(mouseup, onMouseup);
110
- activeEventTypes.delete(mousedown);
111
109
  }
112
110
  };
113
111
  function parseBinding(_ref3) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "137.2.5",
3
+ "version": "137.2.6",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -109,7 +109,7 @@
109
109
  "@gitlab/fonts": "^1.3.1",
110
110
  "@gitlab/hybrid-vue": "npm:@vue/compat@3.5.34",
111
111
  "@gitlab/svgs": "*",
112
- "@jest/test-sequencer": "30.5.1",
112
+ "@jest/test-sequencer": "30.5.2",
113
113
  "@rollup/plugin-commonjs": "^28.0.9",
114
114
  "@rollup/plugin-node-resolve": "^16.0.3",
115
115
  "@rollup/plugin-replace": "^6.0.3",
@@ -131,7 +131,7 @@
131
131
  "@vue/compiler-sfc": "3.5.32",
132
132
  "@vue/server-renderer": "3.5.32",
133
133
  "@vue/test-utils": "1.3.6",
134
- "@vue/test-utils-vue3": "npm:@vue/test-utils@^2.5.0",
134
+ "@vue/test-utils-vue3": "npm:@vue/test-utils@^2.5.1",
135
135
  "@vue/vue2-jest": "29.2.6",
136
136
  "@vue/vue3-jest": "^29.2.6",
137
137
  "@yarnpkg/lockfile": "^1.1.0",
@@ -147,10 +147,10 @@
147
147
  "gitlab-api-async-iterator": "^1.3.1",
148
148
  "glob": "11.1.0",
149
149
  "identity-obj-proxy": "^3.0.0",
150
- "jest": "30.5.1",
151
- "jest-circus": "30.5.1",
152
- "jest-environment-jsdom": "30.5.1",
153
- "jest-environment-node": "30.5.1",
150
+ "jest": "30.5.2",
151
+ "jest-circus": "30.5.2",
152
+ "jest-environment-jsdom": "30.5.2",
153
+ "jest-environment-node": "30.5.2",
154
154
  "jest-image-snapshot": "^6.5.2",
155
155
  "merge-cobertura": "^1.0.9",
156
156
  "mockdate": "^3.0.5",
@@ -175,7 +175,7 @@
175
175
  "start-server-and-test": "^2.1.5",
176
176
  "storybook": "^7.6.24",
177
177
  "storybook-dark-mode": "4.0.2",
178
- "style-dictionary": "^5.5.3",
178
+ "style-dictionary": "^5.5.4",
179
179
  "style-loader": "^4",
180
180
  "tailwindcss": "3.4.19",
181
181
  "vue": "2.7.16",
@@ -276,7 +276,7 @@ export default {
276
276
  </div>
277
277
  </gl-dropdown-item>
278
278
 
279
- <gl-dropdown-item v-else-if="!dropdownItems.length" role="option" disabled>
279
+ <gl-dropdown-item v-else-if="!dropdownItems.length && !loading" role="option" disabled>
280
280
  <slot name="no-results-content">No matches found</slot>
281
281
  </gl-dropdown-item>
282
282
 
@@ -68,19 +68,17 @@ const mousedown = 'mousedown';
68
68
  const mouseup = 'mouseup';
69
69
 
70
70
  const startListening = (eventTypes) => {
71
+ // Listening to mouse events ensures that a text selection doesn't trigger the
72
+ // GlOutsideDirective 'click' callback if the selection started within the target element,
73
+ // and that a Safari focus-loss 'focusin' doesn't trigger the callback either. Nothing is
74
+ // listening yet when the set is empty, so this is bound exactly once.
75
+ if (activeEventTypes.size === 0) {
76
+ document.addEventListener(mousedown, onMousedown);
77
+ document.addEventListener(mouseup, onMouseup);
78
+ }
79
+
71
80
  eventTypes.forEach((eventType) => {
72
81
  if (!activeEventTypes.has(eventType)) {
73
- // Listening to mousedown events, ensures that a text selection doesn't trigger the
74
- // GlOutsideDirective 'click' callback if the selection started within the target element,
75
- // and that a Safari focus-loss 'focusin' doesn't trigger the callback either. Tracked via
76
- // activeEventTypes too, so it's only ever bound/unbound once, regardless of whether 'click'
77
- // and 'focusin' are (de)activated together or separately.
78
- if ((eventType === click || eventType === focusin) && !activeEventTypes.has(mousedown)) {
79
- document.addEventListener(mousedown, onMousedown);
80
- document.addEventListener(mouseup, onMouseup);
81
- activeEventTypes.add(mousedown);
82
- }
83
-
84
82
  // Added { capture: true } to all event types to prevent the behavior discussed in https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/1686#note_412545027
85
83
  // Ensures the event listener handles the event in the capturing phase, avoiding issues encountered previously.
86
84
  // Cannot be tested with Jest or Cypress, but can be tested with Playwright in the future: https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/4272#note_1947425384
@@ -97,21 +95,16 @@ const stopListening = (eventTypesToUnbind) => {
97
95
  eventTypesToUnbind.forEach((eventType) => {
98
96
  if (activeEventTypes.has(eventType)) {
99
97
  if ([...callbacks.values()].every(({ eventTypes }) => !eventTypes.includes(eventType))) {
100
- document.removeEventListener(eventType, globalListener);
98
+ document.removeEventListener(eventType, globalListener, { capture: true });
101
99
  activeEventTypes.delete(eventType);
102
100
  }
103
101
  }
104
102
  });
105
103
 
106
- // Only unbind mousedown once neither 'click' nor 'focusin' need it anymore.
107
- if (
108
- activeEventTypes.has(mousedown) &&
109
- !activeEventTypes.has(click) &&
110
- !activeEventTypes.has(focusin)
111
- ) {
104
+ // Nothing is listening anymore, so the mouse gesture tracking isn't needed either.
105
+ if (activeEventTypes.size === 0) {
112
106
  document.removeEventListener(mousedown, onMousedown);
113
107
  document.removeEventListener(mouseup, onMouseup);
114
- activeEventTypes.delete(mousedown);
115
108
  }
116
109
  };
117
110