@gitlab/ui 72.9.0 → 72.10.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [72.10.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v72.9.0...v72.10.0) (2024-01-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlListbox:** add default SR search results ([92642c8](https://gitlab.com/gitlab-org/gitlab-ui/commit/92642c881813aaab65800312f28d74efd7be772a))
7
+
1
8
  # [72.9.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v72.8.1...v72.9.0) (2024-01-19)
2
9
 
3
10
 
@@ -9,6 +9,7 @@ import GlLoadingIcon from '../../loading_icon/loading_icon';
9
9
  import GlIntersectionObserver from '../../../utilities/intersection_observer/intersection_observer';
10
10
  import GlSearchBoxByType from '../../search_box_by_type/search_box_by_type';
11
11
  import GlBaseDropdown from '../base_dropdown/base_dropdown';
12
+ import { translate } from '../../../../utils/i18n';
12
13
  import GlListboxItem from './listbox_item';
13
14
  import GlListboxSearchInput from './listbox_search_input';
14
15
  import GlListboxGroup from './listbox_group';
@@ -322,6 +323,17 @@ var script = {
322
323
  type: Boolean,
323
324
  required: false,
324
325
  default: false
326
+ },
327
+ srOnlyResultsLabel: {
328
+ type: Function,
329
+ required: false,
330
+ default: count => {
331
+ const fn = translate('GlCollapsibleListbox.srOnlyResultsLabel', 'Results count');
332
+ if (typeof fn === 'function') {
333
+ return fn(count);
334
+ }
335
+ return `${count} result${count > 1 ? 's' : ''}`;
336
+ }
325
337
  }
326
338
  },
327
339
  data() {
@@ -386,7 +398,7 @@ var script = {
386
398
  return !this.flattenedOptions.length && !this.searching;
387
399
  },
388
400
  announceSRSearchResults() {
389
- return this.searchable && !this.showNoResultsText && this.$scopedSlots['search-summary-sr-only'];
401
+ return this.searchable && !this.showNoResultsText;
390
402
  },
391
403
  headerId() {
392
404
  return this.headerText && uniqueId('listbox-header-');
@@ -719,7 +731,7 @@ var script = {
719
731
  const __vue_script__ = script;
720
732
 
721
733
  /* template */
722
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-base-dropdown',{ref:"baseDropdown",attrs:{"aria-haspopup":"listbox","aria-labelledby":_vm.toggleAriaLabelledBy,"block":_vm.block,"toggle-id":_vm.toggleId,"toggle-text":_vm.listboxToggleText,"toggle-class":_vm.toggleButtonClasses,"text-sr-only":_vm.textSrOnly,"category":_vm.category,"variant":_vm.variant,"size":_vm.size,"icon":_vm.icon,"disabled":_vm.disabled,"loading":_vm.loading,"no-caret":_vm.noCaret,"placement":_vm.placement,"offset":_vm.dropdownOffset,"fluid-width":_vm.fluidWidth,"positioning-strategy":_vm.positioningStrategy},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(){return [_vm._t("toggle")]},proxy:true}:null],null,true)},[_vm._v(" "),(_vm.headerText)?_c('div',{staticClass:"gl-display-flex gl-align-items-center gl-p-4! gl-min-h-8",class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('div',{staticClass:"gl-flex-grow-1 gl-font-weight-bold gl-font-sm gl-pr-2",attrs:{"id":_vm.headerId,"data-testid":"listbox-header-text"}},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]),_vm._v(" "),(_vm.showResetButton)?_c('gl-button',{staticClass:"gl-focus-inset-border-2-blue-400! gl-flex-shrink-0 gl-font-sm! gl-px-2! gl-py-2! gl-w-auto! gl-m-0! gl-max-w-50p gl-text-overflow-ellipsis",attrs:{"category":"tertiary","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.showSelectAllButton)?_c('gl-button',{staticClass:"gl-focus-inset-border-2-blue-400! gl-flex-shrink-0 gl-font-sm! gl-px-2! gl-py-2! gl-w-auto! gl-m-0! gl-max-w-50p gl-text-overflow-ellipsis",attrs:{"category":"tertiary","data-testid":"listbox-select-all-button"},on:{"click":_vm.onSelectAllButtonClicked}},[_vm._v("\n "+_vm._s(_vm.showSelectAllButtonLabel)+"\n ")]):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.searchable)?_c('div',{class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('gl-listbox-search-input',{ref:"searchBox",class:{ 'gl-listbox-topmost': !_vm.headerText },attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input","placeholder":_vm.searchPlaceholder},on:{"input":_vm.search,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }$event.preventDefault();},_vm.onKeydown]},model:{value:(_vm.searchStr),callback:function ($$v) {_vm.searchStr=$$v;},expression:"searchStr"}}),_vm._v(" "),(_vm.searching)?_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-search-loader","size":"md"}}):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.showList)?_c(_vm.listboxTag,{ref:"list",tag:"component",staticClass:"gl-new-dropdown-contents gl-new-dropdown-contents-with-scrim-overlay",class:_vm.listboxClasses,attrs:{"id":_vm.listboxId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"0"},on:{"keydown":_vm.onKeydown}},[_c(_vm.itemTag,{tag:"component",staticClass:"top-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"top-scrim"}},[_c('div',{staticClass:"top-scrim",class:{ 'top-scrim-light': !_vm.hasHeader, 'top-scrim-dark': _vm.hasHeader }})]),_vm._v(" "),_c(_vm.itemTag,{ref:"top-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_vm._l((_vm.items),function(item,index){return [(_vm.isOption(item))?[_c('gl-listbox-item',_vm._b({key:item.value,attrs:{"data-testid":("listbox-item-" + (item.value)),"is-selected":_vm.isSelected(item),"is-focused":_vm.isFocused(item),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},'gl-listbox-item',_vm.listboxItemMoreItemsAriaAttributes(index),false),[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(item.text)+"\n ")]},{"item":item})],2)]:[_c('gl-listbox-group',{key:item.text,class:_vm.groupClasses(index),attrs:{"name":item.text,"text-sr-only":item.textSrOnly},scopedSlots:_vm._u([(_vm.$scopedSlots['group-label'])?{key:"group-label",fn:function(){return [_vm._t("group-label",null,{"group":item})]},proxy:true}:null],null,true)},[_vm._v(" "),_vm._l((item.options),function(option){return _c('gl-listbox-item',{key:option.value,attrs:{"data-testid":("listbox-item-" + (option.value)),"is-selected":_vm.isSelected(option),"is-focused":_vm.isFocused(option),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(option, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(option.text)+"\n ")]},{"item":option})],2)})],2)]]}),_vm._v(" "),(_vm.infiniteScrollLoading)?_c(_vm.itemTag,{tag:"component"},[_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-infinite-scroll-loader","size":"md"}})],1):_vm._e(),_vm._v(" "),(_vm.showIntersectionObserver)?_c('gl-intersection-observer',{on:{"appear":_vm.onIntersectionObserverAppear}}):_vm._e(),_vm._v(" "),_c(_vm.itemTag,{ref:"bottom-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_c(_vm.itemTag,{tag:"component",staticClass:"bottom-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"bottom-scrim"}},[_c('div',{staticClass:"bottom-scrim",class:{ 'gl-rounded-0!': _vm.hasFooter }})])],2):_vm._e(),_vm._v(" "),(_vm.announceSRSearchResults)?_c('span',{staticClass:"gl-sr-only",attrs:{"data-testid":"listbox-number-of-results","aria-live":"assertive"}},[_vm._t("search-summary-sr-only")],2):(_vm.showNoResultsText)?_c('div',{staticClass:"gl-pl-7 gl-pr-5 gl-py-3 gl-font-base gl-text-gray-600",attrs:{"aria-live":"assertive","data-testid":"listbox-no-results-text"}},[_vm._v("\n "+_vm._s(_vm.noResultsText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("footer")],2)};
734
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-base-dropdown',{ref:"baseDropdown",attrs:{"aria-haspopup":"listbox","aria-labelledby":_vm.toggleAriaLabelledBy,"block":_vm.block,"toggle-id":_vm.toggleId,"toggle-text":_vm.listboxToggleText,"toggle-class":_vm.toggleButtonClasses,"text-sr-only":_vm.textSrOnly,"category":_vm.category,"variant":_vm.variant,"size":_vm.size,"icon":_vm.icon,"disabled":_vm.disabled,"loading":_vm.loading,"no-caret":_vm.noCaret,"placement":_vm.placement,"offset":_vm.dropdownOffset,"fluid-width":_vm.fluidWidth,"positioning-strategy":_vm.positioningStrategy},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(){return [_vm._t("toggle")]},proxy:true}:null],null,true)},[_vm._v(" "),(_vm.headerText)?_c('div',{staticClass:"gl-display-flex gl-align-items-center gl-p-4! gl-min-h-8",class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('div',{staticClass:"gl-flex-grow-1 gl-font-weight-bold gl-font-sm gl-pr-2",attrs:{"id":_vm.headerId,"data-testid":"listbox-header-text"}},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]),_vm._v(" "),(_vm.showResetButton)?_c('gl-button',{staticClass:"gl-focus-inset-border-2-blue-400! gl-flex-shrink-0 gl-font-sm! gl-px-2! gl-py-2! gl-w-auto! gl-m-0! gl-max-w-50p gl-text-overflow-ellipsis",attrs:{"category":"tertiary","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.showSelectAllButton)?_c('gl-button',{staticClass:"gl-focus-inset-border-2-blue-400! gl-flex-shrink-0 gl-font-sm! gl-px-2! gl-py-2! gl-w-auto! gl-m-0! gl-max-w-50p gl-text-overflow-ellipsis",attrs:{"category":"tertiary","data-testid":"listbox-select-all-button"},on:{"click":_vm.onSelectAllButtonClicked}},[_vm._v("\n "+_vm._s(_vm.showSelectAllButtonLabel)+"\n ")]):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.searchable)?_c('div',{class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('gl-listbox-search-input',{ref:"searchBox",class:{ 'gl-listbox-topmost': !_vm.headerText },attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input","placeholder":_vm.searchPlaceholder},on:{"input":_vm.search,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }$event.preventDefault();},_vm.onKeydown]},model:{value:(_vm.searchStr),callback:function ($$v) {_vm.searchStr=$$v;},expression:"searchStr"}}),_vm._v(" "),(_vm.searching)?_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-search-loader","size":"md"}}):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.showList)?_c(_vm.listboxTag,{ref:"list",tag:"component",staticClass:"gl-new-dropdown-contents gl-new-dropdown-contents-with-scrim-overlay",class:_vm.listboxClasses,attrs:{"id":_vm.listboxId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"0"},on:{"keydown":_vm.onKeydown}},[_c(_vm.itemTag,{tag:"component",staticClass:"top-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"top-scrim"}},[_c('div',{staticClass:"top-scrim",class:{ 'top-scrim-light': !_vm.hasHeader, 'top-scrim-dark': _vm.hasHeader }})]),_vm._v(" "),_c(_vm.itemTag,{ref:"top-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_vm._l((_vm.items),function(item,index){return [(_vm.isOption(item))?[_c('gl-listbox-item',_vm._b({key:item.value,attrs:{"data-testid":("listbox-item-" + (item.value)),"is-selected":_vm.isSelected(item),"is-focused":_vm.isFocused(item),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},'gl-listbox-item',_vm.listboxItemMoreItemsAriaAttributes(index),false),[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(item.text)+"\n ")]},{"item":item})],2)]:[_c('gl-listbox-group',{key:item.text,class:_vm.groupClasses(index),attrs:{"name":item.text,"text-sr-only":item.textSrOnly},scopedSlots:_vm._u([(_vm.$scopedSlots['group-label'])?{key:"group-label",fn:function(){return [_vm._t("group-label",null,{"group":item})]},proxy:true}:null],null,true)},[_vm._v(" "),_vm._l((item.options),function(option){return _c('gl-listbox-item',{key:option.value,attrs:{"data-testid":("listbox-item-" + (option.value)),"is-selected":_vm.isSelected(option),"is-focused":_vm.isFocused(option),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(option, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(option.text)+"\n ")]},{"item":option})],2)})],2)]]}),_vm._v(" "),(_vm.infiniteScrollLoading)?_c(_vm.itemTag,{tag:"component"},[_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-infinite-scroll-loader","size":"md"}})],1):_vm._e(),_vm._v(" "),(_vm.showIntersectionObserver)?_c('gl-intersection-observer',{on:{"appear":_vm.onIntersectionObserverAppear}}):_vm._e(),_vm._v(" "),_c(_vm.itemTag,{ref:"bottom-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_c(_vm.itemTag,{tag:"component",staticClass:"bottom-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"bottom-scrim"}},[_c('div',{staticClass:"bottom-scrim",class:{ 'gl-rounded-0!': _vm.hasFooter }})])],2):_vm._e(),_vm._v(" "),(_vm.announceSRSearchResults)?_c('span',{staticClass:"gl-sr-only",attrs:{"data-testid":"listbox-number-of-results","aria-live":"assertive"}},[_vm._t("search-summary-sr-only",function(){return [_vm._v("\n "+_vm._s(_vm.srOnlyResultsLabel(_vm.flattenedOptions.length))+"\n ")]})],2):(_vm.showNoResultsText)?_c('div',{staticClass:"gl-pl-7 gl-pr-5 gl-py-3 gl-font-base gl-text-gray-600",attrs:{"aria-live":"assertive","data-testid":"listbox-no-results-text"}},[_vm._v("\n "+_vm._s(_vm.noResultsText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("footer")],2)};
723
735
  var __vue_staticRenderFns__ = [];
724
736
 
725
737
  /* style */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 19 Jan 2024 02:24:13 GMT
3
+ * Generated on Fri, 19 Jan 2024 13:53:09 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 19 Jan 2024 02:24:13 GMT
3
+ * Generated on Fri, 19 Jan 2024 13:53:09 GMT
4
4
  */
5
5
 
6
6
  :root.gl-dark {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 19 Jan 2024 02:24:13 GMT
3
+ * Generated on Fri, 19 Jan 2024 13:53:09 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#133a03";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 19 Jan 2024 02:24:13 GMT
3
+ * Generated on Fri, 19 Jan 2024 13:53:09 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#ddfab7";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Fri, 19 Jan 2024 02:24:13 GMT
3
+ // Generated on Fri, 19 Jan 2024 13:53:09 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 Fri, 19 Jan 2024 02:24:13 GMT
3
+ // Generated on Fri, 19 Jan 2024 13:53:09 GMT
4
4
 
5
5
  $gl-line-height-52: 3.25rem;
6
6
  $gl-line-height-44: 2.75rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "72.9.0",
3
+ "version": "72.10.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -134,7 +134,8 @@ To update content of the listbox, toggle the `searching` property
134
134
  and update the `items` property with a new array. Be sure to debounce (or
135
135
  similar) the `search` event handler to avoid rendering stale results.
136
136
  To improve the accessibility, provide the `search-summary-sr-only` scoped slot
137
- with a number of found search results text.
137
+ with a number of found search results text, alternately, you can pass a plural translate function.
138
+ An example of the plural translate function can be found [the GitLab Docs internationalization section](https://docs.gitlab.com/ee/development/i18n/externalization.html#plurals)
138
139
  Screen reader will announce this text when the list is updated.
139
140
 
140
141
  ```html
@@ -477,6 +477,11 @@ describe('GlCollapsibleListbox', () => {
477
477
  });
478
478
 
479
479
  describe('Screen reader text with number of search results', () => {
480
+ it('when the #search-summary-sr-only slot content is empty', () => {
481
+ buildWrapper({ items: mockOptions, searchable: true, searching: false });
482
+ expect(findSRNumberOfResultsText().text()).toBe('12 results');
483
+ });
484
+
480
485
  it('when the #search-summary-sr-only slot content is provided', () => {
481
486
  const searchResultsContent = 'Found 5 results';
482
487
  const slots = { 'search-summary-sr-only': searchResultsContent };
@@ -60,6 +60,7 @@ const generateProps = ({
60
60
  startOpened = true,
61
61
  fluidWidth,
62
62
  positioningStrategy,
63
+ srOnlyResultsLabel,
63
64
  } = {}) => ({
64
65
  items,
65
66
  category,
@@ -90,6 +91,7 @@ const generateProps = ({
90
91
  startOpened,
91
92
  fluidWidth,
92
93
  positioningStrategy,
94
+ srOnlyResultsLabel,
93
95
  });
94
96
 
95
97
  const makeBindings = (overrides = {}) =>
@@ -123,6 +125,7 @@ const makeBindings = (overrides = {}) =>
123
125
  ':fluid-width': 'fluidWidth',
124
126
  ':positioning-strategy': 'positioningStrategy',
125
127
  ':startOpened': 'startOpened',
128
+ ':sr-only-results-label': 'srOnlyResultsLabel',
126
129
  ...overrides,
127
130
  })
128
131
  .map(([key, value]) => `${key}="${value}"`)
@@ -577,6 +580,11 @@ export default {
577
580
  subcategory: ARG_TYPE_SUBCATEGORY_ACCESSIBILITY,
578
581
  },
579
582
  },
583
+ srOnlyResultsLabel: {
584
+ table: {
585
+ subcategory: ARG_TYPE_SUBCATEGORY_ACCESSIBILITY,
586
+ },
587
+ },
580
588
  listAriaLabelledBy: {
581
589
  table: {
582
590
  subcategory: ARG_TYPE_SUBCATEGORY_ACCESSIBILITY,
@@ -644,7 +652,7 @@ export const Searchable = (args, { argTypes }) => ({
644
652
  return toggleText;
645
653
  },
646
654
  numberOfSearchResults() {
647
- return this.filteredItems.length === 1 ? '1 result' : `${this.filteredItems.length} results`;
655
+ return `${this.filteredItems.length} department${this.filteredItems.length > 1 ? 's' : ''}`;
648
656
  },
649
657
  },
650
658
  template: template(
@@ -700,11 +708,6 @@ export const SearchableGroups = (args, { argTypes }) => ({
700
708
 
701
709
  return toggleText;
702
710
  },
703
- numberOfSearchResults() {
704
- return this.flattenedFilteredOptions.length === 1
705
- ? '1 result'
706
- : `${this.flattenedFilteredOptions.length} results`;
707
- },
708
711
  },
709
712
  methods: {
710
713
  filterList(searchTerm) {
@@ -729,20 +732,19 @@ export const SearchableGroups = (args, { argTypes }) => ({
729
732
  this.searchInProgress = false;
730
733
  }, 2000);
731
734
  },
735
+ srOnlyResultsLabel(count) {
736
+ return `${count} branch${count > 1 ? 'es' : ''} or tag${count > 1 ? 's' : ''}`;
737
+ },
732
738
  },
733
- template: template(
734
- `<template #search-summary-sr-only>
735
- {{ numberOfSearchResults }}
736
- </template>`,
737
- {
738
- bindingOverrides: {
739
- ':items': 'filteredGroupOptions',
740
- ':toggle-text': 'customToggleText',
741
- ':searching': 'searchInProgress',
742
- '@search': 'filterList',
743
- },
744
- }
745
- ),
739
+ template: template('', {
740
+ bindingOverrides: {
741
+ ':items': 'filteredGroupOptions',
742
+ ':toggle-text': 'customToggleText',
743
+ ':searching': 'searchInProgress',
744
+ ':sr-only-results-label': 'srOnlyResultsLabel',
745
+ '@search': 'filterList',
746
+ },
747
+ }),
746
748
  });
747
749
  SearchableGroups.args = generateProps({
748
750
  headerText: 'Select ref',
@@ -26,6 +26,7 @@ import GlLoadingIcon from '../../loading_icon/loading_icon.vue';
26
26
  import GlIntersectionObserver from '../../../utilities/intersection_observer/intersection_observer.vue';
27
27
  import GlSearchBoxByType from '../../search_box_by_type/search_box_by_type.vue';
28
28
  import GlBaseDropdown from '../base_dropdown/base_dropdown.vue';
29
+ import { translate } from '../../../../utils/i18n';
29
30
  import GlListboxItem from './listbox_item.vue';
30
31
  import GlListboxSearchInput from './listbox_search_input.vue';
31
32
  import GlListboxGroup from './listbox_group.vue';
@@ -339,6 +340,17 @@ export default {
339
340
  required: false,
340
341
  default: false,
341
342
  },
343
+ srOnlyResultsLabel: {
344
+ type: Function,
345
+ required: false,
346
+ default: (count) => {
347
+ const fn = translate('GlCollapsibleListbox.srOnlyResultsLabel', 'Results count');
348
+ if (typeof fn === 'function') {
349
+ return fn(count);
350
+ }
351
+ return `${count} result${count > 1 ? 's' : ''}`;
352
+ },
353
+ },
342
354
  },
343
355
  data() {
344
356
  return {
@@ -394,9 +406,7 @@ export default {
394
406
  return !this.flattenedOptions.length && !this.searching;
395
407
  },
396
408
  announceSRSearchResults() {
397
- return (
398
- this.searchable && !this.showNoResultsText && this.$scopedSlots['search-summary-sr-only']
399
- );
409
+ return this.searchable && !this.showNoResultsText;
400
410
  },
401
411
  headerId() {
402
412
  return this.headerText && uniqueId('listbox-header-');
@@ -912,7 +922,9 @@ export default {
912
922
  aria-live="assertive"
913
923
  >
914
924
  <!-- @slot Text read by screen reader announcing a number of search results -->
915
- <slot name="search-summary-sr-only"></slot>
925
+ <slot name="search-summary-sr-only">
926
+ {{ srOnlyResultsLabel(flattenedOptions.length) }}
927
+ </slot>
916
928
  </span>
917
929
 
918
930
  <div
package/translations.json CHANGED
@@ -3,5 +3,6 @@
3
3
  "GlSorting.sortAscending": "Sort direction: ascending",
4
4
  "GlSorting.sortDescending": "Sort direction: descending",
5
5
  "GlSearchBoxByType.clearButtonTitle": "Clear",
6
- "GlSearchBoxByType.input.placeholder": "Search"
6
+ "GlSearchBoxByType.input.placeholder": "Search",
7
+ "GlCollapsibleListbox.srOnlyResultsLabel": "Results count"
7
8
  }