Merge branch 'auto-focus-description-field' into 'issue-edit-inline'
Focus the description field in the inline form when mounted See merge request !11441
This commit is contained in:
commit
f5675666a1
2 changed files with 38 additions and 1 deletions
|
@ -20,6 +20,9 @@
|
|||
components: {
|
||||
markdownField,
|
||||
},
|
||||
mounted() {
|
||||
this.$refs.textarea.focus();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -39,7 +42,7 @@
|
|||
data-supports-slash-commands="false"
|
||||
aria-label="Description"
|
||||
v-model="formState.description"
|
||||
ref="textatea"
|
||||
ref="textarea"
|
||||
slot="textarea">
|
||||
</textarea>
|
||||
</markdown-field>
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
import Vue from 'vue';
|
||||
import descriptionField from '~/issue_show/components/fields/description.vue';
|
||||
|
||||
describe('Description field component', () => {
|
||||
let vm;
|
||||
|
||||
beforeEach((done) => {
|
||||
const Component = Vue.extend(descriptionField);
|
||||
|
||||
// Needs an el in the DOM to be able to test the element is focused
|
||||
const el = document.createElement('div');
|
||||
|
||||
document.body.appendChild(el);
|
||||
|
||||
vm = new Component({
|
||||
el,
|
||||
propsData: {
|
||||
formState: {
|
||||
description: '',
|
||||
},
|
||||
markdownDocs: '/',
|
||||
markdownPreviewUrl: '/',
|
||||
},
|
||||
}).$mount();
|
||||
|
||||
Vue.nextTick(done);
|
||||
});
|
||||
|
||||
it('focuses field when mounted', () => {
|
||||
expect(
|
||||
document.activeElement,
|
||||
).toBe(vm.$refs.textarea);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue