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 {
'assignIssueToEpic',
'removeIssueFromEpic',
]),
focusInput() {
this.$refs.search.focusInput();
},
handleItemSelect(epic) {
if (
this.selectedEpicIssueId &&
......@@ -248,10 +251,15 @@ export default {
:header-text="dropdownHeaderText"
@keydown.esc.native="hideDropdown"
@hide="hideDropdown"
@shown="focusInput"
@toggle="toggleFormDropdown"
>
<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 v-if="epicListValid">
<gl-dropdown-item
......
import { GlLoadingIcon, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { GlLoadingIcon, GlDropdown, GlDropdownItem, GlSearchBoxByType } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import { DropdownVariant } from 'ee/vue_shared/components/sidebar/epics_select//constants';
import EpicsSelectBase from 'ee/vue_shared/components/sidebar/epics_select/base.vue';
......@@ -16,17 +16,16 @@ describe('EpicsSelect', () => {
let wrapperStandalone;
const store = createDefaultStore();
const storeStandalone = createDefaultStore();
const props = {
canEdit: true,
initialEpic: mockEpic1,
initialEpicLoading: false,
epicIssueId: mockIssue.epic_issue_id,
groupId: mockEpic1.group_id,
issueId: mockIssue.id,
};
beforeEach(() => {
const props = {
canEdit: true,
initialEpic: mockEpic1,
initialEpicLoading: false,
epicIssueId: mockIssue.epic_issue_id,
groupId: mockEpic1.group_id,
issueId: mockIssue.id,
};
wrapper = shallowMount(EpicsSelectBase, {
store,
propsData: {
......@@ -275,6 +274,16 @@ describe('EpicsSelect', () => {
await wrapper.vm.$nextTick();
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