Commit f5675666 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'auto-focus-description-field' into 'issue-edit-inline'

Focus the description field in the inline form when mounted

See merge request !11441
parents 16288e78 9c9a24ce
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
components: { components: {
markdownField, markdownField,
}, },
mounted() {
this.$refs.textarea.focus();
},
}; };
</script> </script>
...@@ -39,7 +42,7 @@ ...@@ -39,7 +42,7 @@
data-supports-slash-commands="false" data-supports-slash-commands="false"
aria-label="Description" aria-label="Description"
v-model="formState.description" v-model="formState.description"
ref="textatea" ref="textarea"
slot="textarea"> slot="textarea">
</textarea> </textarea>
</markdown-field> </markdown-field>
......
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);
});
});
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