Commit 568de4e0 authored by Simon Knox's avatar Simon Knox

Merge branch...

Merge branch '338639-on-issue-creation-clicking-select-epic-does-not-bring-focus-to-search-input-causing-problems' into 'master'

Focus on input when dropdown is shown on issue creation page

See merge request gitlab-org/gitlab!70703
parents e00b70fc 00a431b2
...@@ -184,6 +184,9 @@ export default { ...@@ -184,6 +184,9 @@ export default {
'assignIssueToEpic', 'assignIssueToEpic',
'removeIssueFromEpic', 'removeIssueFromEpic',
]), ]),
focusInput() {
this.$refs.search.focusInput();
},
handleItemSelect(epic) { handleItemSelect(epic) {
if ( if (
this.selectedEpicIssueId && this.selectedEpicIssueId &&
...@@ -248,10 +251,15 @@ export default { ...@@ -248,10 +251,15 @@ export default {
:header-text="dropdownHeaderText" :header-text="dropdownHeaderText"
@keydown.esc.native="hideDropdown" @keydown.esc.native="hideDropdown"
@hide="hideDropdown" @hide="hideDropdown"
@shown="focusInput"
@toggle="toggleFormDropdown" @toggle="toggleFormDropdown"
> >
<template #header> <template #header>
<gl-search-box-by-type v-model.trim="search" :placeholder="$options.i18n.searchEpic" /> <gl-search-box-by-type
ref="search"
v-model.trim="search"
:placeholder="$options.i18n.searchEpic"
/>
</template> </template>
<template v-if="epicListValid"> <template v-if="epicListValid">
<gl-dropdown-item <gl-dropdown-item
......
import { GlLoadingIcon, GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlLoadingIcon, GlDropdown, GlDropdownItem, GlSearchBoxByType } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { DropdownVariant } from 'ee/vue_shared/components/sidebar/epics_select//constants'; import { DropdownVariant } from 'ee/vue_shared/components/sidebar/epics_select//constants';
import EpicsSelectBase from 'ee/vue_shared/components/sidebar/epics_select/base.vue'; import EpicsSelectBase from 'ee/vue_shared/components/sidebar/epics_select/base.vue';
...@@ -16,8 +16,6 @@ describe('EpicsSelect', () => { ...@@ -16,8 +16,6 @@ describe('EpicsSelect', () => {
let wrapperStandalone; let wrapperStandalone;
const store = createDefaultStore(); const store = createDefaultStore();
const storeStandalone = createDefaultStore(); const storeStandalone = createDefaultStore();
beforeEach(() => {
const props = { const props = {
canEdit: true, canEdit: true,
initialEpic: mockEpic1, initialEpic: mockEpic1,
...@@ -27,6 +25,7 @@ describe('EpicsSelect', () => { ...@@ -27,6 +25,7 @@ describe('EpicsSelect', () => {
issueId: mockIssue.id, issueId: mockIssue.id,
}; };
beforeEach(() => {
wrapper = shallowMount(EpicsSelectBase, { wrapper = shallowMount(EpicsSelectBase, {
store, store,
propsData: { propsData: {
...@@ -275,6 +274,16 @@ describe('EpicsSelect', () => { ...@@ -275,6 +274,16 @@ describe('EpicsSelect', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.findComponent(GlDropdown).findComponent(GlLoadingIcon).exists()).toBe(true); expect(wrapper.findComponent(GlDropdown).findComponent(GlLoadingIcon).exists()).toBe(true);
}); });
it('focuses on the input when the dropdown is shown', () => {
wrapper = mount(EpicsSelectBase, { propsData: props });
const spy = jest.spyOn(wrapper.findComponent(GlSearchBoxByType).vm, 'focusInput');
wrapper.findComponent(GlDropdown).vm.$emit('shown');
expect(spy).toHaveBeenCalledTimes(1);
});
}); });
}); });
}); });
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