@gitlab/ui 49.0.0 → 49.0.1
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 +7 -0
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +15 -10
- package/dist/components/base/new_dropdowns/listbox/listbox.js +15 -19
- package/package.json +1 -1
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +1 -0
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +13 -7
- package/src/components/base/new_dropdowns/listbox/listbox.spec.js +13 -7
- package/src/components/base/new_dropdowns/listbox/listbox.vue +12 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [49.0.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v49.0.0...v49.0.1) (2022-10-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **GlListbox:** fix dropdown positioning ([18d061f](https://gitlab.com/gitlab-org/gitlab-ui/commit/18d061fc905ac906a6c88f080b08b9e085eb372e))
|
|
7
|
+
|
|
1
8
|
# [49.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v48.3.1...v49.0.0) (2022-10-24)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -147,14 +147,6 @@ var script = {
|
|
|
147
147
|
|
|
148
148
|
},
|
|
149
149
|
|
|
150
|
-
updated() {
|
|
151
|
-
if (this.visible) {
|
|
152
|
-
var _this$popper;
|
|
153
|
-
|
|
154
|
-
(_this$popper = this.popper) === null || _this$popper === void 0 ? void 0 : _this$popper.update();
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
|
|
158
150
|
mounted() {
|
|
159
151
|
this.$nextTick(() => {
|
|
160
152
|
this.popper = createPopper(this.$refs.toggle.$el, this.$refs.content, this.popperConfig);
|
|
@@ -166,11 +158,24 @@ var script = {
|
|
|
166
158
|
},
|
|
167
159
|
|
|
168
160
|
methods: {
|
|
169
|
-
toggle() {
|
|
161
|
+
async toggle() {
|
|
170
162
|
this.visible = !this.visible;
|
|
171
163
|
|
|
172
164
|
if (this.visible) {
|
|
173
|
-
|
|
165
|
+
var _this$popper;
|
|
166
|
+
|
|
167
|
+
/* Initially dropdown is hidden with `display="none"`.
|
|
168
|
+
When `visible` prop is toggled ON, with the `nextTick` we wait for the DOM update -
|
|
169
|
+
dropdown's `display="block"` is set (adding CSS class `show`).
|
|
170
|
+
After that we can recalculate its position (calling `popper.update()`).
|
|
171
|
+
https://github.com/floating-ui/floating-ui/issues/630:
|
|
172
|
+
"Unfortunately there's not any way to compute the position of an element not rendered in the document".
|
|
173
|
+
Then we `await` while the new dropdown position is calculated and DOM updated accordingly.
|
|
174
|
+
After we can emit the `GL_DROPDOWN_SHOWN` event to the parent which might interact with updated dropdown,
|
|
175
|
+
e.g. set focus..
|
|
176
|
+
*/
|
|
177
|
+
await this.$nextTick();
|
|
178
|
+
await ((_this$popper = this.popper) === null || _this$popper === void 0 ? void 0 : _this$popper.update());
|
|
174
179
|
this.$emit(GL_DROPDOWN_SHOWN);
|
|
175
180
|
} else {
|
|
176
181
|
this.$emit(GL_DROPDOWN_HIDDEN);
|
|
@@ -326,23 +326,21 @@ var script = {
|
|
|
326
326
|
},
|
|
327
327
|
|
|
328
328
|
onShow() {
|
|
329
|
-
this
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var _this$selectedIndices;
|
|
329
|
+
if (this.searchable) {
|
|
330
|
+
this.focusSearchInput();
|
|
331
|
+
} else {
|
|
332
|
+
var _this$selectedIndices;
|
|
334
333
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
334
|
+
this.focusItem((_this$selectedIndices = this.selectedIndices[0]) !== null && _this$selectedIndices !== void 0 ? _this$selectedIndices : 0, this.getFocusableListItemElements());
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Emitted when dropdown is shown
|
|
338
|
+
*
|
|
339
|
+
* @event shown
|
|
340
|
+
*/
|
|
342
341
|
|
|
343
342
|
|
|
344
|
-
|
|
345
|
-
});
|
|
343
|
+
this.$emit(GL_DROPDOWN_SHOWN);
|
|
346
344
|
},
|
|
347
345
|
|
|
348
346
|
onHide() {
|
|
@@ -413,12 +411,10 @@ var script = {
|
|
|
413
411
|
},
|
|
414
412
|
|
|
415
413
|
focusItem(index, elements) {
|
|
416
|
-
|
|
417
|
-
this.$nextTick(() => {
|
|
418
|
-
var _elements$index;
|
|
414
|
+
var _elements$index;
|
|
419
415
|
|
|
420
|
-
|
|
421
|
-
|
|
416
|
+
this.nextFocusedItemIndex = index;
|
|
417
|
+
(_elements$index = elements[index]) === null || _elements$index === void 0 ? void 0 : _elements$index.focus();
|
|
422
418
|
},
|
|
423
419
|
|
|
424
420
|
focusSearchInput() {
|
package/package.json
CHANGED
|
@@ -144,6 +144,7 @@ describe('base dropdown', () => {
|
|
|
144
144
|
await toggle.trigger('click');
|
|
145
145
|
expect(menu.classes('show')).toBe(true);
|
|
146
146
|
expect(toggle.attributes('aria-expanded')).toBe('true');
|
|
147
|
+
await nextTick();
|
|
147
148
|
expect(wrapper.emitted(GL_DROPDOWN_SHOWN).length).toBe(1);
|
|
148
149
|
|
|
149
150
|
// close menu clicking toggle btn again
|
|
@@ -138,11 +138,6 @@ export default {
|
|
|
138
138
|
};
|
|
139
139
|
},
|
|
140
140
|
},
|
|
141
|
-
updated() {
|
|
142
|
-
if (this.visible) {
|
|
143
|
-
this.popper?.update();
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
141
|
mounted() {
|
|
147
142
|
this.$nextTick(() => {
|
|
148
143
|
this.popper = createPopper(this.$refs.toggle.$el, this.$refs.content, this.popperConfig);
|
|
@@ -152,11 +147,22 @@ export default {
|
|
|
152
147
|
this.popper.destroy();
|
|
153
148
|
},
|
|
154
149
|
methods: {
|
|
155
|
-
toggle() {
|
|
150
|
+
async toggle() {
|
|
156
151
|
this.visible = !this.visible;
|
|
157
152
|
|
|
158
153
|
if (this.visible) {
|
|
159
|
-
|
|
154
|
+
/* Initially dropdown is hidden with `display="none"`.
|
|
155
|
+
When `visible` prop is toggled ON, with the `nextTick` we wait for the DOM update -
|
|
156
|
+
dropdown's `display="block"` is set (adding CSS class `show`).
|
|
157
|
+
After that we can recalculate its position (calling `popper.update()`).
|
|
158
|
+
https://github.com/floating-ui/floating-ui/issues/630:
|
|
159
|
+
"Unfortunately there's not any way to compute the position of an element not rendered in the document".
|
|
160
|
+
Then we `await` while the new dropdown position is calculated and DOM updated accordingly.
|
|
161
|
+
After we can emit the `GL_DROPDOWN_SHOWN` event to the parent which might interact with updated dropdown,
|
|
162
|
+
e.g. set focus..
|
|
163
|
+
*/
|
|
164
|
+
await this.$nextTick();
|
|
165
|
+
await this.popper?.update();
|
|
160
166
|
this.$emit(GL_DROPDOWN_SHOWN);
|
|
161
167
|
} else {
|
|
162
168
|
this.$emit(GL_DROPDOWN_HIDDEN);
|
|
@@ -247,19 +247,25 @@ describe('GlListbox', () => {
|
|
|
247
247
|
});
|
|
248
248
|
|
|
249
249
|
describe('when `searchable` is enabled', () => {
|
|
250
|
-
|
|
250
|
+
let searchbox;
|
|
251
|
+
|
|
252
|
+
beforeEach(() => {
|
|
251
253
|
buildWrapper({ items: mockOptions, searchable: true });
|
|
252
254
|
findBaseDropdown().vm.$emit(GL_DROPDOWN_SHOWN);
|
|
253
|
-
|
|
255
|
+
firstItem = findListItem(0);
|
|
256
|
+
searchbox = findSearchBox();
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('should move focus to the first item on search input `ARROW_DOWN`', async () => {
|
|
260
|
+
expect(searchbox.element).toHaveFocus();
|
|
261
|
+
searchbox.trigger('keydown', { code: ARROW_DOWN });
|
|
254
262
|
expect(firstItem.element).toHaveFocus();
|
|
255
263
|
});
|
|
256
264
|
|
|
257
265
|
it('should move focus to the search input on first item `ARROW_UP', async () => {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
await firstItem.trigger('keydown', { code: ARROW_UP });
|
|
262
|
-
expect(focusSpy).toHaveBeenCalled();
|
|
266
|
+
searchbox.trigger('keydown', { code: ARROW_DOWN });
|
|
267
|
+
firstItem.trigger('keydown', { code: ARROW_UP });
|
|
268
|
+
expect(searchbox.element).toHaveFocus();
|
|
263
269
|
});
|
|
264
270
|
});
|
|
265
271
|
});
|
|
@@ -293,19 +293,17 @@ export default {
|
|
|
293
293
|
return index === 0 ? null : GROUP_TOP_BORDER_CLASSES;
|
|
294
294
|
},
|
|
295
295
|
onShow() {
|
|
296
|
-
this
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
this.$emit(GL_DROPDOWN_SHOWN);
|
|
308
|
-
});
|
|
296
|
+
if (this.searchable) {
|
|
297
|
+
this.focusSearchInput();
|
|
298
|
+
} else {
|
|
299
|
+
this.focusItem(this.selectedIndices[0] ?? 0, this.getFocusableListItemElements());
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Emitted when dropdown is shown
|
|
303
|
+
*
|
|
304
|
+
* @event shown
|
|
305
|
+
*/
|
|
306
|
+
this.$emit(GL_DROPDOWN_SHOWN);
|
|
309
307
|
},
|
|
310
308
|
onHide() {
|
|
311
309
|
/**
|
|
@@ -366,9 +364,7 @@ export default {
|
|
|
366
364
|
focusItem(index, elements) {
|
|
367
365
|
this.nextFocusedItemIndex = index;
|
|
368
366
|
|
|
369
|
-
|
|
370
|
-
elements[index]?.focus();
|
|
371
|
-
});
|
|
367
|
+
elements[index]?.focus();
|
|
372
368
|
},
|
|
373
369
|
focusSearchInput() {
|
|
374
370
|
this.$refs.searchBox.focusInput();
|