Commit 39b6ddf2 authored by Florie Guibert's avatar Florie Guibert

Fix labels widget update on close on Ubuntu

parent b20d0415
...@@ -87,9 +87,6 @@ export default { ...@@ -87,9 +87,6 @@ export default {
return isDropdownVariantStandalone(this.variant); return isDropdownVariantStandalone(this.variant);
}, },
}, },
mounted() {
this.$refs.dropdown.show();
},
methods: { methods: {
toggleDropdownContentsCreateView() { toggleDropdownContentsCreateView() {
this.showDropdownContentsCreateView = !this.showDropdownContentsCreateView; this.showDropdownContentsCreateView = !this.showDropdownContentsCreateView;
...@@ -101,6 +98,9 @@ export default { ...@@ -101,6 +98,9 @@ export default {
this.$refs.dropdown.$refs.dropdown.$_popper.scheduleUpdate(); this.$refs.dropdown.$refs.dropdown.$_popper.scheduleUpdate();
} }
}, },
showDropdown() {
this.$refs.dropdown.show();
},
closeDropdown() { closeDropdown() {
this.$emit('setLabels', this.localSelectedLabels); this.$emit('setLabels', this.localSelectedLabels);
this.$refs.dropdown.hide(); this.$refs.dropdown.hide();
......
...@@ -141,6 +141,9 @@ export default { ...@@ -141,6 +141,9 @@ export default {
handleCollapsedValueClick() { handleCollapsedValueClick() {
this.$emit('toggleCollapse'); this.$emit('toggleCollapse');
}, },
showDropdownContents() {
this.$refs.dropdownContents.showDropdown();
},
isDropdownVariantSidebar, isDropdownVariantSidebar,
isDropdownVariantStandalone, isDropdownVariantStandalone,
isDropdownVariantEmbedded, isDropdownVariantEmbedded,
...@@ -167,6 +170,7 @@ export default { ...@@ -167,6 +170,7 @@ export default {
:title="__('Labels')" :title="__('Labels')"
:loading="isLoading" :loading="isLoading"
:can-edit="allowLabelEdit" :can-edit="allowLabelEdit"
@open="showDropdownContents"
> >
<template #collapsed> <template #collapsed>
<dropdown-value <dropdown-value
...@@ -180,7 +184,7 @@ export default { ...@@ -180,7 +184,7 @@ export default {
<slot></slot> <slot></slot>
</dropdown-value> </dropdown-value>
</template> </template>
<template #default="{ edit }"> <template #default>
<dropdown-value <dropdown-value
:disable-labels="labelsSelectInProgress" :disable-labels="labelsSelectInProgress"
:selected-labels="issuableLabels" :selected-labels="issuableLabels"
...@@ -193,7 +197,7 @@ export default { ...@@ -193,7 +197,7 @@ export default {
<slot></slot> <slot></slot>
</dropdown-value> </dropdown-value>
<dropdown-contents <dropdown-contents
v-if="edit" ref="dropdownContents"
:dropdown-button-text="dropdownButtonText" :dropdown-button-text="dropdownButtonText"
:allow-multiselect="allowMultiselect" :allow-multiselect="allowMultiselect"
:labels-list-title="labelsListTitle" :labels-list-title="labelsListTitle"
......
...@@ -68,10 +68,11 @@ describe('DropdownContent', () => { ...@@ -68,10 +68,11 @@ describe('DropdownContent', () => {
const findCreateLabelButton = () => wrapper.find('[data-testid="create-label-button"]'); const findCreateLabelButton = () => wrapper.find('[data-testid="create-label-button"]');
const findGoBackButton = () => wrapper.find('[data-testid="go-back-button"]'); const findGoBackButton = () => wrapper.find('[data-testid="go-back-button"]');
it('calls dropdown `show` method on component mount', () => { it('emits `show` for dropdown on call showDropdown', () => {
createComponent(); createComponent();
wrapper.vm.showDropdown();
expect(showDropdown).toHaveBeenCalled(); expect(findDropdown().emitted('show')).toBeUndefined();
}); });
it('emits `setLabels` event on dropdown hide', () => { it('emits `setLabels` event on dropdown hide', () => {
......
...@@ -128,6 +128,13 @@ describe('LabelsSelectRoot', () => { ...@@ -128,6 +128,13 @@ describe('LabelsSelectRoot', () => {
it('emits `updateSelectedLabels` event on dropdown contents `setLabels` event if there are labels to update', async () => { it('emits `updateSelectedLabels` event on dropdown contents `setLabels` event if there are labels to update', async () => {
const label = { id: 'gid://gitlab/ProjectLabel/1' }; const label = { id: 'gid://gitlab/ProjectLabel/1' };
createComponent(); createComponent();
wrapper.vm.$refs.dropdownContents = {
showDropdown: jest.fn(),
};
const showSpy = jest.spyOn(wrapper.vm.$refs.dropdownContents, 'showDropdown');
findDropdownContents().vm.$refs.dropdown = {
show: jest.fn(),
};
await waitForPromises(); await waitForPromises();
expandDropdown(); expandDropdown();
...@@ -135,5 +142,6 @@ describe('LabelsSelectRoot', () => { ...@@ -135,5 +142,6 @@ describe('LabelsSelectRoot', () => {
findDropdownContents().vm.$emit('setLabels', [label]); findDropdownContents().vm.$emit('setLabels', [label]);
expect(wrapper.emitted('updateSelectedLabels')).toEqual([[[label]]]); expect(wrapper.emitted('updateSelectedLabels')).toEqual([[[label]]]);
expect(showSpy).toHaveBeenCalled();
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment