@gitlab/ui 131.1.0 → 131.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.
@@ -327,10 +327,15 @@ var script = {
327
327
  // Preserve the active token's active status (it shifted down one index)
328
328
  this.activeTokenIdx -= 1;
329
329
  } else if (idx === this.activeTokenIdx) {
330
- // User destroyed the active token; don't activate another one.
331
- this.activeTokenIdx = null;
330
+ // User destroyed the active token; activate the last token so focus
331
+ // moves to the search input rather than being lost.
332
+ this.activeTokenIdx = this.lastTokenIdx;
333
+ } else if (this.activeTokenIdx === null) {
334
+ // No token was active (e.g. clicking the X button on an inactive token);
335
+ // activate the last token so focus moves to the search input.
336
+ this.activeTokenIdx = this.lastTokenIdx;
332
337
  }
333
- // Do nothing if there was no active token, or if idx > this.activeTokenIdx,
338
+ // Do nothing if idx > this.activeTokenIdx,
334
339
  // to preserve the active state of the remaining tokens.
335
340
  },
336
341
  replaceToken(idx, token) {
@@ -365,6 +370,12 @@ var script = {
365
370
  this.activeTokenIdx = null;
366
371
  }
367
372
  },
373
+ onClear() {
374
+ this.$nextTick(() => {
375
+ this.activeTokenIdx = this.lastTokenIdx;
376
+ this.$emit('clear');
377
+ });
378
+ },
368
379
  submit() {
369
380
  /**
370
381
  * Emitted when search is submitted
@@ -379,7 +390,7 @@ var script = {
379
390
  const __vue_script__ = script;
380
391
 
381
392
  /* template */
382
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-search-box-by-click',_vm._b({attrs:{"value":_vm.tokens,"history-items":_vm.historyItems,"clearable":_vm.hasValue,"search-button-attributes":_vm.searchButtonAttributes,"show-search-button":_vm.showSearchButton,"disabled":_vm.viewOnly,"wrapper-attributes":{ 'data-testid': 'filtered-search-input' }},on:{"submit":_vm.submit,"input":_vm.applyNewValue,"history-item-selected":function($event){return _vm.$emit('history-item-selected', $event)},"clear":function($event){return _vm.$emit('clear')},"clear-history":function($event){return _vm.$emit('clear-history')}},scopedSlots:_vm._u([{key:"history-item",fn:function(slotScope){return [_vm._t("history-item",null,null,slotScope)]}},{key:"input",fn:function(){return [_c('div',{staticClass:"gl-filtered-search-scrollable-container",class:{
393
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-search-box-by-click',_vm._b({attrs:{"value":_vm.tokens,"history-items":_vm.historyItems,"clearable":_vm.hasValue,"search-button-attributes":_vm.searchButtonAttributes,"show-search-button":_vm.showSearchButton,"disabled":_vm.viewOnly,"wrapper-attributes":{ 'data-testid': 'filtered-search-input' }},on:{"submit":_vm.submit,"input":_vm.applyNewValue,"history-item-selected":function($event){return _vm.$emit('history-item-selected', $event)},"clear":_vm.onClear,"clear-history":function($event){return _vm.$emit('clear-history')}},scopedSlots:_vm._u([{key:"history-item",fn:function(slotScope){return [_vm._t("history-item",null,null,slotScope)]}},{key:"input",fn:function(){return [_c('div',{staticClass:"gl-filtered-search-scrollable-container",class:{
383
394
  'gl-filtered-search-scrollable-container-with-search-button': _vm.showSearchButton,
384
395
  'gl-filtered-search-view-only': _vm.viewOnly,
385
396
  }},[_c('div',{staticClass:"gl-filtered-search-scrollable"},_vm._l((_vm.tokens),function(token,idx){return _c(_vm.getTokenComponent(token.type),{key:token.id,ref:"tokens",refInFor:true,tag:"component",class:_vm.getTokenClassList(idx),attrs:{"config":_vm.getTokenEntry(token.type),"active":_vm.activeTokenIdx === idx,"cursor-position":_vm.intendedCursorPosition,"available-tokens":_vm.currentAvailableTokens,"current-value":_vm.tokens,"index":idx,"placeholder":_vm.termPlaceholder,"show-friendly-text":_vm.showFriendlyText,"search-input-attributes":_vm.searchInputAttributes,"view-only":_vm.viewOnly,"is-last-token":_vm.isLastToken(idx),"search-text-option-label":_vm.searchTextOptionLabel,"applied-tokens":_vm.appliedTokens},on:{"activate":function($event){return _vm.activate(idx)},"deactivate":function($event){return _vm.deactivate(token)},"destroy":function($event){return _vm.destroyToken(idx, $event)},"replace":function($event){return _vm.replaceToken(idx, $event)},"complete":_vm.completeToken,"submit":_vm.submit,"split":function($event){return _vm.createTokens(idx, $event)},"previous":_vm.activatePreviousToken,"next":_vm.activateNextToken},model:{value:(token.value),callback:function ($$v) {_vm.$set(token, "value", $$v);},expression:"token.value"}})}),1)]),_vm._v(" "),_c('portal-target',{key:_vm.activeTokenIdx,ref:"menu",style:(_vm.suggestionsStyle),attrs:{"name":_vm.portalName,"slim":""}})]},proxy:true}],null,true)},'gl-search-box-by-click',_vm.$attrs,false))};
@@ -89,7 +89,7 @@ var script = {
89
89
  },
90
90
  computed: {
91
91
  showInput() {
92
- return this.termsAsTokens() || Boolean(this.placeholder);
92
+ return this.termsAsTokens() || Boolean(this.placeholder) || this.isLastToken;
93
93
  },
94
94
  showToken() {
95
95
  return this.termsAsTokens() && Boolean(this.value.data);
@@ -409,7 +409,7 @@ const __vue_script__ = script;
409
409
  var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._g(_vm._b({staticClass:"gl-filtered-search-token-segment",class:{
410
410
  'gl-filtered-search-token-segment-active': _vm.active,
411
411
  '!gl-cursor-text': _vm.viewOnly,
412
- },attrs:{"data-testid":"filtered-search-token-segment"}},'div',_vm.containerAttributes,false),_vm.viewOnly ? {} : { mousedown: _vm.emitIfInactive }),[(_vm.active)?[_vm._t("before-input",null,null,{ submitValue: _vm.applySuggestion }),_vm._v(" "),_vm._t("input",function(){return [(((_vm.searchInputAttributes).type)==='checkbox')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",class:{ 'gl-filtered-search-token-segment-input-disabled': _vm.viewOnly },attrs:{"data-testid":"filtered-search-token-segment-input","aria-label":_vm.label,"disabled":_vm.viewOnly,"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.inputValue)?_vm._i(_vm.inputValue,null)>-1:(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){var $$a=_vm.inputValue,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.inputValue=$$a.concat([$$v]));}else {$$i>-1&&(_vm.inputValue=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else {_vm.inputValue=$$c;}}}},'input',_vm.searchInputAttributes,false)):(((_vm.searchInputAttributes).type)==='radio')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",class:{ 'gl-filtered-search-token-segment-input-disabled': _vm.viewOnly },attrs:{"data-testid":"filtered-search-token-segment-input","aria-label":_vm.label,"disabled":_vm.viewOnly,"type":"radio"},domProps:{"checked":_vm._q(_vm.inputValue,null)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){_vm.inputValue=null;}}},'input',_vm.searchInputAttributes,false)):_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",class:{ 'gl-filtered-search-token-segment-input-disabled': _vm.viewOnly },attrs:{"data-testid":"filtered-search-token-segment-input","aria-label":_vm.label,"disabled":_vm.viewOnly,"type":(_vm.searchInputAttributes).type},domProps:{"value":(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"input":function($event){if($event.target.composing){ return; }_vm.inputValue=$event.target.value;}}},'input',_vm.searchInputAttributes,false))]},null,{ submitValue: _vm.applySuggestion }),_vm._v(" "),_c('portal',{key:("operator-" + _vm._uid),attrs:{"to":_vm.portalName}},[(_vm.hasOptionsOrSuggestions)?_c('gl-filtered-search-suggestion-list',{key:("operator-" + _vm._uid),ref:"suggestions",attrs:{"role":"list","tabindex":"0","initial-value":_vm.defaultSuggestedValue},on:{"suggestion":_vm.applySuggestion}},[(_vm.options)?[_vm._l((_vm.options),function(option,idx){return [(_vm.showHeader(option))?[(idx > 0)?_c('li',{key:("separator-" + idx)},[_c('hr',{staticClass:"gl-border-t -gl-mx-2 gl-my-2"})]):_vm._e(),_vm._v(" "),_c('li',{key:("header-" + idx),staticClass:"gl-mx-0 gl-pb-2 gl-pl-5 gl-pt-3 gl-text-sm gl-font-bold gl-text-strong",attrs:{"role":"presentation","data-testid":"filtered-search-section-header"}},[_vm._v("\n "+_vm._s(option.title)+"\n ")])]:_c('gl-filtered-search-suggestion',{key:((option.value) + "-" + idx),attrs:{"value":option.value,"icon-name":option.icon}},[_vm._t("option",function(){return [(option.component)?[_c(option.component,{tag:"component",attrs:{"option":option}})]:[_vm._v("\n "+_vm._s(option[_vm.optionTextField])+"\n ")]]},null,{ option: option })],2)]})]:_vm._t("suggestions")],2):_vm._e()],1)]:_vm._t("view",function(){return [_vm._v(_vm._s(_vm.inputValue))]},null,{ label: _vm.label, inputValue: _vm.inputValue })],2)};
412
+ },attrs:{"data-testid":"filtered-search-token-segment"}},'div',_vm.containerAttributes,false),_vm.viewOnly ? {} : { mousedown: _vm.emitIfInactive }),[(_vm.active)?[_vm._t("before-input",null,null,{ submitValue: _vm.applySuggestion }),_vm._v(" "),_vm._t("input",function(){return [(((_vm.searchInputAttributes).type)==='checkbox')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",class:{ 'gl-filtered-search-token-segment-input-disabled': _vm.viewOnly },attrs:{"data-testid":"filtered-search-token-segment-input","aria-label":_vm.label,"disabled":_vm.viewOnly,"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.inputValue)?_vm._i(_vm.inputValue,null)>-1:(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){var $$a=_vm.inputValue,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.inputValue=$$a.concat([$$v]));}else {$$i>-1&&(_vm.inputValue=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else {_vm.inputValue=$$c;}}}},'input',_vm.searchInputAttributes,false)):(((_vm.searchInputAttributes).type)==='radio')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",class:{ 'gl-filtered-search-token-segment-input-disabled': _vm.viewOnly },attrs:{"data-testid":"filtered-search-token-segment-input","aria-label":_vm.label,"disabled":_vm.viewOnly,"type":"radio"},domProps:{"checked":_vm._q(_vm.inputValue,null)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){_vm.inputValue=null;}}},'input',_vm.searchInputAttributes,false)):_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",class:{ 'gl-filtered-search-token-segment-input-disabled': _vm.viewOnly },attrs:{"data-testid":"filtered-search-token-segment-input","aria-label":_vm.label,"disabled":_vm.viewOnly,"type":(_vm.searchInputAttributes).type},domProps:{"value":(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"input":function($event){if($event.target.composing){ return; }_vm.inputValue=$event.target.value;}}},'input',_vm.searchInputAttributes,false))]},null,{ submitValue: _vm.applySuggestion }),_vm._v(" "),_c('portal',{key:("operator-" + _vm._uid),attrs:{"to":_vm.portalName}},[(_vm.hasOptionsOrSuggestions)?_c('gl-filtered-search-suggestion-list',{key:("operator-" + _vm._uid),ref:"suggestions",attrs:{"role":"list","tabindex":"-1","data-testid":"filtered-search-suggestion-list","initial-value":_vm.defaultSuggestedValue},on:{"suggestion":_vm.applySuggestion}},[(_vm.options)?[_vm._l((_vm.options),function(option,idx){return [(_vm.showHeader(option))?[(idx > 0)?_c('li',{key:("separator-" + idx)},[_c('hr',{staticClass:"gl-border-t -gl-mx-2 gl-my-2"})]):_vm._e(),_vm._v(" "),_c('li',{key:("header-" + idx),staticClass:"gl-mx-0 gl-pb-2 gl-pl-5 gl-pt-3 gl-text-sm gl-font-bold gl-text-strong",attrs:{"role":"presentation","data-testid":"filtered-search-section-header"}},[_vm._v("\n "+_vm._s(option.title)+"\n ")])]:_c('gl-filtered-search-suggestion',{key:((option.value) + "-" + idx),attrs:{"value":option.value,"icon-name":option.icon}},[_vm._t("option",function(){return [(option.component)?[_c(option.component,{tag:"component",attrs:{"option":option}})]:[_vm._v("\n "+_vm._s(option[_vm.optionTextField])+"\n ")]]},null,{ option: option })],2)]})]:_vm._t("suggestions")],2):_vm._e()],1)]:_vm._t("view",function(){return [_vm._v(_vm._s(_vm.inputValue))]},null,{ label: _vm.label, inputValue: _vm.inputValue })],2)};
413
413
  var __vue_staticRenderFns__ = [];
414
414
 
415
415
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "131.1.0",
3
+ "version": "131.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -101,7 +101,7 @@
101
101
  "@babel/preset-env": "^7.29.2",
102
102
  "@babel/preset-react": "^7.28.5",
103
103
  "@cypress/grep": "^4.1.1",
104
- "@figma/code-connect": "^1.4.2",
104
+ "@figma/code-connect": "^1.4.3",
105
105
  "@gitlab/fonts": "^1.3.1",
106
106
  "@gitlab/svgs": "*",
107
107
  "@jest/test-sequencer": "30.3.0",
@@ -349,10 +349,15 @@ export default {
349
349
  // Preserve the active token's active status (it shifted down one index)
350
350
  this.activeTokenIdx -= 1;
351
351
  } else if (idx === this.activeTokenIdx) {
352
- // User destroyed the active token; don't activate another one.
353
- this.activeTokenIdx = null;
352
+ // User destroyed the active token; activate the last token so focus
353
+ // moves to the search input rather than being lost.
354
+ this.activeTokenIdx = this.lastTokenIdx;
355
+ } else if (this.activeTokenIdx === null) {
356
+ // No token was active (e.g. clicking the X button on an inactive token);
357
+ // activate the last token so focus moves to the search input.
358
+ this.activeTokenIdx = this.lastTokenIdx;
354
359
  }
355
- // Do nothing if there was no active token, or if idx > this.activeTokenIdx,
360
+ // Do nothing if idx > this.activeTokenIdx,
356
361
  // to preserve the active state of the remaining tokens.
357
362
  },
358
363
 
@@ -388,6 +393,13 @@ export default {
388
393
  }
389
394
  },
390
395
 
396
+ onClear() {
397
+ this.$nextTick(() => {
398
+ this.activeTokenIdx = this.lastTokenIdx;
399
+ this.$emit('clear');
400
+ });
401
+ },
402
+
391
403
  submit() {
392
404
  /**
393
405
  * Emitted when search is submitted
@@ -412,7 +424,7 @@ export default {
412
424
  @submit="submit"
413
425
  @input="applyNewValue"
414
426
  @history-item-selected="$emit('history-item-selected', $event)"
415
- @clear="$emit('clear')"
427
+ @clear="onClear"
416
428
  @clear-history="$emit('clear-history')"
417
429
  >
418
430
  <template #history-item="slotScope">
@@ -94,7 +94,7 @@ export default {
94
94
  },
95
95
  computed: {
96
96
  showInput() {
97
- return this.termsAsTokens() || Boolean(this.placeholder);
97
+ return this.termsAsTokens() || Boolean(this.placeholder) || this.isLastToken;
98
98
  },
99
99
  showToken() {
100
100
  return this.termsAsTokens() && Boolean(this.value.data);
@@ -470,7 +470,8 @@ export default {
470
470
  :key="`operator-${_uid}`"
471
471
  ref="suggestions"
472
472
  role="list"
473
- tabindex="0"
473
+ tabindex="-1"
474
+ data-testid="filtered-search-suggestion-list"
474
475
  :initial-value="defaultSuggestedValue"
475
476
  @suggestion="applySuggestion"
476
477
  >