@gitlab/ui 54.4.0 → 55.0.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 +20 -0
- package/dist/components/base/new_dropdowns/constants.js +3 -3
- package/dist/components/base/new_dropdowns/listbox/listbox.js +1 -1
- package/dist/components/base/search_box_by_type/search_box_by_type.js +27 -11
- package/package.json +3 -3
- package/src/components/base/new_dropdowns/constants.js +3 -3
- package/src/components/base/new_dropdowns/listbox/listbox.spec.js +22 -0
- package/src/components/base/new_dropdowns/listbox/listbox.vue +1 -0
- package/src/components/base/search_box_by_type/search_box_by_type.spec.js +18 -10
- package/src/components/base/search_box_by_type/search_box_by_type.vue +28 -13
- package/src/scss/fonts.scss +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [55.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v54.4.1...v55.0.0) (2023-02-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlSearchBoxByType:** implemented component wide focusin focusout ([c202cde](https://gitlab.com/gitlab-org/gitlab-ui/commit/c202cde2374542c0b2b6608acc84f52390783e76))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **GlSearchBoxByType:** removes `clearButtonFocus`, `clearButtonBlur`, and
|
|
12
|
+
`clearButtonRelease` events.
|
|
13
|
+
|
|
14
|
+
## [54.4.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v54.4.0...v54.4.1) (2023-02-06)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **GlListbox:** Stop listbox ENTER event prop ([944b7f9](https://gitlab.com/gitlab-org/gitlab-ui/commit/944b7f9baf67fc71787d14d614fb51b722083820))
|
|
20
|
+
|
|
1
21
|
# [54.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v54.3.0...v54.4.0) (2023-02-02)
|
|
2
22
|
|
|
3
23
|
|
|
@@ -12,11 +12,11 @@ const GL_DROPDOWN_SHOWN = 'shown';
|
|
|
12
12
|
const GL_DROPDOWN_HIDDEN = 'hidden';
|
|
13
13
|
|
|
14
14
|
// KEY Codes
|
|
15
|
-
const HOME = 'Home';
|
|
16
|
-
const END = 'End';
|
|
17
|
-
const ARROW_UP = 'ArrowUp';
|
|
18
15
|
const ARROW_DOWN = 'ArrowDown';
|
|
16
|
+
const ARROW_UP = 'ArrowUp';
|
|
17
|
+
const END = 'End';
|
|
19
18
|
const ENTER = 'Enter';
|
|
19
|
+
const HOME = 'Home';
|
|
20
20
|
const SPACE = 'Space';
|
|
21
21
|
|
|
22
22
|
export { ARROW_DOWN, ARROW_UP, END, ENTER, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_SHOWN, HOME, POPPER_CONFIG, SPACE };
|
|
@@ -536,7 +536,7 @@ var script = {
|
|
|
536
536
|
const __vue_script__ = script;
|
|
537
537
|
|
|
538
538
|
/* template */
|
|
539
|
-
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.toggleClass,"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},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!",attrs:{"category":"tertiary","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\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",attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input","placeholder":_vm.searchPlaceholder},on:{"input":_vm.search,"keydown":_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",attrs:{"id":_vm.listboxId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},[_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},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.listboxTag === 'ul' ? 'li' : 'div',{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()],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)};
|
|
539
|
+
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.toggleClass,"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},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!",attrs:{"category":"tertiary","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\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",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",attrs:{"id":_vm.listboxId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},[_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},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.listboxTag === 'ul' ? 'li' : 'div',{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()],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)};
|
|
540
540
|
var __vue_staticRenderFns__ = [];
|
|
541
541
|
|
|
542
542
|
/* style */
|
|
@@ -78,9 +78,9 @@ var script = {
|
|
|
78
78
|
inputListeners() {
|
|
79
79
|
return {
|
|
80
80
|
...this.$listeners,
|
|
81
|
-
input:
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
input: this.onInput,
|
|
82
|
+
focusin: this.onFocusin,
|
|
83
|
+
focusout: this.onFocusout
|
|
84
84
|
};
|
|
85
85
|
},
|
|
86
86
|
showClearButton() {
|
|
@@ -88,21 +88,37 @@ var script = {
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
methods: {
|
|
91
|
+
isInputOrClearButton(element) {
|
|
92
|
+
var _this$$refs$input, _this$$refs$clearButt;
|
|
93
|
+
return element === ((_this$$refs$input = this.$refs.input) === null || _this$$refs$input === void 0 ? void 0 : _this$$refs$input.$el) || element === ((_this$$refs$clearButt = this.$refs.clearButton) === null || _this$$refs$clearButt === void 0 ? void 0 : _this$$refs$clearButt.$el);
|
|
94
|
+
},
|
|
91
95
|
clearInput() {
|
|
92
|
-
this
|
|
96
|
+
this.onInput('');
|
|
93
97
|
this.focusInput();
|
|
94
98
|
},
|
|
95
99
|
focusInput() {
|
|
96
100
|
this.$refs.input.$el.focus();
|
|
97
101
|
},
|
|
98
|
-
|
|
99
|
-
this.$emit('
|
|
102
|
+
onInput(value) {
|
|
103
|
+
this.$emit('input', value);
|
|
100
104
|
},
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
onFocusout(event) {
|
|
106
|
+
const {
|
|
107
|
+
relatedTarget
|
|
108
|
+
} = event;
|
|
109
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.$emit('focusout', event);
|
|
103
113
|
},
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
onFocusin(event) {
|
|
115
|
+
const {
|
|
116
|
+
relatedTarget
|
|
117
|
+
} = event;
|
|
118
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.$emit('focusin', event);
|
|
106
122
|
}
|
|
107
123
|
}
|
|
108
124
|
};
|
|
@@ -114,7 +130,7 @@ const __vue_script__ = script;
|
|
|
114
130
|
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-search-box-by-type"},[_c('gl-icon',{staticClass:"gl-search-box-by-type-search-icon",attrs:{"name":"search"}}),_vm._v(" "),_c('gl-form-input',_vm._g(_vm._b({ref:"input",class:{
|
|
115
131
|
'gl-search-box-by-type-input': !_vm.borderless,
|
|
116
132
|
'gl-search-box-by-type-input-borderless': _vm.borderless,
|
|
117
|
-
},attrs:{"value":_vm.value,"disabled":_vm.disabled}},'gl-form-input',_vm.inputAttributes,false),_vm.inputListeners)),_vm._v(" "),(_vm.isLoading || _vm.showClearButton)?_c('div',{staticClass:"gl-search-box-by-type-right-icons"},[(_vm.isLoading)?_c('gl-loading-icon',{staticClass:"gl-search-box-by-type-loading-icon"}):_vm._e(),_vm._v(" "),(_vm.showClearButton)?_c('gl-clear-icon-button',{staticClass:"gl-search-box-by-type-clear gl-clear-icon-button",attrs:{"title":_vm.clearButtonTitle,"tooltip-container":_vm.tooltipContainer},on:{"click":function($event){$event.stopPropagation();return _vm.clearInput.apply(null, arguments)},"
|
|
133
|
+
},attrs:{"value":_vm.value,"disabled":_vm.disabled}},'gl-form-input',_vm.inputAttributes,false),_vm.inputListeners)),_vm._v(" "),(_vm.isLoading || _vm.showClearButton)?_c('div',{staticClass:"gl-search-box-by-type-right-icons"},[(_vm.isLoading)?_c('gl-loading-icon',{staticClass:"gl-search-box-by-type-loading-icon"}):_vm._e(),_vm._v(" "),(_vm.showClearButton)?_c('gl-clear-icon-button',{ref:"clearButton",staticClass:"gl-search-box-by-type-clear gl-clear-icon-button",attrs:{"title":_vm.clearButtonTitle,"tooltip-container":_vm.tooltipContainer},on:{"click":function($event){$event.stopPropagation();return _vm.clearInput.apply(null, arguments)},"focusin":_vm.onFocusin,"focusout":_vm.onFocusout}}):_vm._e()],1):_vm._e()],1)};
|
|
118
134
|
var __vue_staticRenderFns__ = [];
|
|
119
135
|
|
|
120
136
|
/* style */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "55.0.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"clean": "rm -r dist storybook scss_to_js/scss_variables.* src/scss/utilities.scss",
|
|
30
30
|
"cy:run": "cypress run --browser firefox",
|
|
31
31
|
"start": "yarn storybook",
|
|
32
|
-
"storybook": "yarn storybook-prep && start-storybook --ci --host localhost --port 9001 -c .storybook
|
|
32
|
+
"storybook": "yarn storybook-prep && start-storybook --ci --host localhost --port 9001 -c .storybook",
|
|
33
33
|
"storybook-prep": "run-s generate-utilities build-scss-variables copy-fonts",
|
|
34
|
-
"storybook-static": "yarn storybook-prep && build-storybook -c .storybook -o storybook
|
|
34
|
+
"storybook-static": "yarn storybook-prep && build-storybook -c .storybook -o storybook",
|
|
35
35
|
"pretest:unit": "yarn build-scss-variables",
|
|
36
36
|
"test": "run-s test:unit test:visual",
|
|
37
37
|
"test:integration": "NODE_ENV=test start-server-and-test start http://localhost:9001 cy:run",
|
|
@@ -14,9 +14,9 @@ export const GL_DROPDOWN_SHOWN = 'shown';
|
|
|
14
14
|
export const GL_DROPDOWN_HIDDEN = 'hidden';
|
|
15
15
|
|
|
16
16
|
// KEY Codes
|
|
17
|
-
export const HOME = 'Home';
|
|
18
|
-
export const END = 'End';
|
|
19
|
-
export const ARROW_UP = 'ArrowUp';
|
|
20
17
|
export const ARROW_DOWN = 'ArrowDown';
|
|
18
|
+
export const ARROW_UP = 'ArrowUp';
|
|
19
|
+
export const END = 'End';
|
|
21
20
|
export const ENTER = 'Enter';
|
|
21
|
+
export const HOME = 'Home';
|
|
22
22
|
export const SPACE = 'Space';
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ARROW_UP,
|
|
10
10
|
HOME,
|
|
11
11
|
END,
|
|
12
|
+
ENTER,
|
|
12
13
|
} from '../constants';
|
|
13
14
|
import GlIntersectionObserver from '../../../utilities/intersection_observer/intersection_observer.vue';
|
|
14
15
|
import GlListbox, { ITEM_SELECTOR } from './listbox.vue';
|
|
@@ -273,6 +274,27 @@ describe('GlListbox', () => {
|
|
|
273
274
|
firstItem.trigger('keydown', { code: ARROW_UP });
|
|
274
275
|
expect(searchboxInput.element).toHaveFocus();
|
|
275
276
|
});
|
|
277
|
+
|
|
278
|
+
describe('pressing Enter on the input', () => {
|
|
279
|
+
const keydownSpy = jest.fn();
|
|
280
|
+
|
|
281
|
+
beforeEach(() => {
|
|
282
|
+
keydownSpy.mockClear();
|
|
283
|
+
wrapper.element.addEventListener('keydown', keydownSpy);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
afterEach(() => {
|
|
287
|
+
wrapper.element.removeEventListener('keydown', keydownSpy);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('does not submit any ancestor form', async () => {
|
|
291
|
+
searchboxInput.trigger('keydown', { key: ENTER });
|
|
292
|
+
|
|
293
|
+
const [event] = keydownSpy.mock.calls[0];
|
|
294
|
+
expect(event.key).toBe(ENTER);
|
|
295
|
+
expect(event.defaultPrevented).toBe(true);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
276
298
|
});
|
|
277
299
|
});
|
|
278
300
|
|
|
@@ -57,22 +57,30 @@ describe('search box by type component', () => {
|
|
|
57
57
|
expect(wrapper.emitted('input')).toEqual([['']]);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it('emits
|
|
61
|
-
|
|
60
|
+
it('emits `focusin` event when focus inside the component', () => {
|
|
61
|
+
findInput().vm.$emit('focusin', { preventDefault: jest.fn() });
|
|
62
62
|
|
|
63
|
-
expect(wrapper.emitted('
|
|
63
|
+
expect(wrapper.emitted('focus')).toBe(undefined);
|
|
64
|
+
expect(wrapper.emitted('focusin')).toHaveLength(1);
|
|
64
65
|
});
|
|
66
|
+
it('emits `focusout` event when focus moves outside the component', () => {
|
|
67
|
+
findInput().vm.$emit('focusout', { preventDefault: jest.fn() });
|
|
68
|
+
expect(wrapper.emitted('blur')).toBe(undefined);
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
findClearIcon().vm.$emit('blur', { stopPropagation: jest.fn() });
|
|
68
|
-
|
|
69
|
-
expect(wrapper.emitted('clearButtonBlur')).toHaveLength(1);
|
|
70
|
+
expect(wrapper.emitted('focusout')).toHaveLength(1);
|
|
70
71
|
});
|
|
71
72
|
|
|
72
|
-
it('
|
|
73
|
-
|
|
73
|
+
it('does NOT emit `focusout` event when tabbing inside the component back and forth', () => {
|
|
74
|
+
findInput().vm.$emit('focusout', {
|
|
75
|
+
preventDefault: jest.fn(),
|
|
76
|
+
relatedTarget: wrapper.vm.$refs.input.$el,
|
|
77
|
+
});
|
|
78
|
+
findClearIcon().vm.$emit('focusout', {
|
|
79
|
+
preventDefault: jest.fn(),
|
|
80
|
+
relatedTarget: wrapper.vm.$refs.clearButton.$el,
|
|
81
|
+
});
|
|
74
82
|
|
|
75
|
-
expect(wrapper.emitted('
|
|
83
|
+
expect(wrapper.emitted('focusout')).toBe(undefined);
|
|
76
84
|
});
|
|
77
85
|
});
|
|
78
86
|
|
|
@@ -81,9 +81,9 @@ export default {
|
|
|
81
81
|
inputListeners() {
|
|
82
82
|
return {
|
|
83
83
|
...this.$listeners,
|
|
84
|
-
input:
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
input: this.onInput,
|
|
85
|
+
focusin: this.onFocusin,
|
|
86
|
+
focusout: this.onFocusout,
|
|
87
87
|
};
|
|
88
88
|
},
|
|
89
89
|
showClearButton() {
|
|
@@ -91,21 +91,36 @@ export default {
|
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
93
|
methods: {
|
|
94
|
+
isInputOrClearButton(element) {
|
|
95
|
+
return element === this.$refs.input?.$el || element === this.$refs.clearButton?.$el;
|
|
96
|
+
},
|
|
94
97
|
clearInput() {
|
|
95
|
-
this
|
|
98
|
+
this.onInput('');
|
|
96
99
|
this.focusInput();
|
|
97
100
|
},
|
|
98
101
|
focusInput() {
|
|
99
102
|
this.$refs.input.$el.focus();
|
|
100
103
|
},
|
|
101
|
-
|
|
102
|
-
this.$emit('
|
|
104
|
+
onInput(value) {
|
|
105
|
+
this.$emit('input', value);
|
|
103
106
|
},
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
onFocusout(event) {
|
|
108
|
+
const { relatedTarget } = event;
|
|
109
|
+
|
|
110
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this.$emit('focusout', event);
|
|
106
115
|
},
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
onFocusin(event) {
|
|
117
|
+
const { relatedTarget } = event;
|
|
118
|
+
|
|
119
|
+
if (this.isInputOrClearButton(relatedTarget)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.$emit('focusin', event);
|
|
109
124
|
},
|
|
110
125
|
},
|
|
111
126
|
};
|
|
@@ -129,13 +144,13 @@ export default {
|
|
|
129
144
|
<gl-loading-icon v-if="isLoading" class="gl-search-box-by-type-loading-icon" />
|
|
130
145
|
<gl-clear-icon-button
|
|
131
146
|
v-if="showClearButton"
|
|
147
|
+
ref="clearButton"
|
|
132
148
|
:title="clearButtonTitle"
|
|
133
149
|
:tooltip-container="tooltipContainer"
|
|
134
150
|
class="gl-search-box-by-type-clear gl-clear-icon-button"
|
|
135
151
|
@click.stop="clearInput"
|
|
136
|
-
@
|
|
137
|
-
@
|
|
138
|
-
@release="onClearButtonRelease"
|
|
152
|
+
@focusin="onFocusin"
|
|
153
|
+
@focusout="onFocusout"
|
|
139
154
|
/>
|
|
140
155
|
</div>
|
|
141
156
|
</div>
|
package/src/scss/fonts.scss
CHANGED
|
@@ -14,7 +14,7 @@ Usage:
|
|
|
14
14
|
font-display: block;
|
|
15
15
|
font-style: normal;
|
|
16
16
|
font-named-instance: 'Regular'; /* stylelint-disable property-no-unknown */
|
|
17
|
-
src: url('/fonts/GitLabSans.woff2') format('woff2');
|
|
17
|
+
src: url('../../static/fonts/GitLabSans.woff2') format('woff2');
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/* -------------------------------------------------------
|
|
@@ -31,5 +31,5 @@ Usage:
|
|
|
31
31
|
*/
|
|
32
32
|
font-display: block;
|
|
33
33
|
font-style: normal;
|
|
34
|
-
src: url('/fonts/JetBrainsMono.woff2') format('woff2');
|
|
34
|
+
src: url('../../static/fonts/JetBrainsMono.woff2') format('woff2');
|
|
35
35
|
}
|