summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-05-17 14:35:02 +0100
committerPhil Hughes <me@iamphill.com>2017-05-17 14:35:02 +0100
commit292780272e41740102eca2630a681887d137e67e (patch)
tree379829914a37fac23fc87c3b734f488fe656cbb1
parent4fcff0bfa2f0d8b0a9f60e93bee807334557918f (diff)
downloadgitlab-ce-292780272e41740102eca2630a681887d137e67e.tar.gz
Focus the description field in the inline form when mounted
[ci skip]
-rw-r--r--app/assets/javascripts/issue_show/components/fields/description.vue5
-rw-r--r--spec/javascripts/issue_show/components/fields/description_spec.js34
2 files changed, 38 insertions, 1 deletions
diff --git a/app/assets/javascripts/issue_show/components/fields/description.vue b/app/assets/javascripts/issue_show/components/fields/description.vue
index b4c31811a0b..35b1ea6ff2b 100644
--- a/app/assets/javascripts/issue_show/components/fields/description.vue
+++ b/app/assets/javascripts/issue_show/components/fields/description.vue
@@ -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>
diff --git a/spec/javascripts/issue_show/components/fields/description_spec.js b/spec/javascripts/issue_show/components/fields/description_spec.js
new file mode 100644
index 00000000000..6ea52feb84f
--- /dev/null
+++ b/spec/javascripts/issue_show/components/fields/description_spec.js
@@ -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 text 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);
+ });
+});