diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-11-01 01:16:29 +0000 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-11-01 01:16:29 +0000 |
commit | af13ffbcedd8952433d4d3f6693aac3450c5fa6f (patch) | |
tree | 41d41b187f3ac1a47b909fef250664d158ffd04e /app/assets/javascripts/vue_shared/components/markdown/header.vue | |
parent | 9c3f094a2f7609386ed182e4d5f6f9e7f6938388 (diff) | |
download | gitlab-ce-af13ffbcedd8952433d4d3f6693aac3450c5fa6f.tar.gz |
Dont emit toggle-markdown event if current target is already active and add specs
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/markdown/header.vue')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/markdown/header.vue | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/assets/javascripts/vue_shared/components/markdown/header.vue b/app/assets/javascripts/vue_shared/components/markdown/header.vue index 5bf2a90cc3b..ef1c2dcf638 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/header.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/header.vue @@ -16,12 +16,18 @@ toolbarButton, }, methods: { + isMarkdownForm(form) { + return form && !form.find('.js-vue-markdown-field').length; + }, + + isActiveTarget(target) { + return target.closest('li').classList.contains('active'); + }, + toggleMarkdownPreview(e, form) { - if (form && !form.find('.js-vue-markdown-field').length) { - return; - } else if (e.target.blur) { - e.target.blur(); - } + if (e.target.blur) e.target.blur(); + + if (this.isMarkdownForm(form) || this.isActiveTarget(e.target)) return; this.$emit('toggle-markdown'); }, |