summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorClement Ho <clemmakesapps@gmail.com>2017-02-01 22:48:57 +0000
committerClement Ho <clemmakesapps@gmail.com>2017-02-01 22:48:57 +0000
commit40a824357c700280f3d2f8e2cda2fabc65af7f69 (patch)
tree00ee357bd8c34ac60f7e6be155a6c450f2a892cb /app
parent6d5421271325357ffdd94269c4602291835c5c1e (diff)
parentcd582d3c19843e776cf4aaf151753ec61a9e56ef (diff)
downloadgitlab-ce-40a824357c700280f3d2f8e2cda2fabc65af7f69.tar.gz
Merge branch 'empty-selection-reply-shortcut' into 'master'
Change the reply shortcut to focus the field even without a selection. See merge request !8873
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/lib/utils/common_utils.js.es61
-rw-r--r--app/assets/javascripts/shortcuts_issuable.js9
2 files changed, 7 insertions, 3 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js.es6 b/app/assets/javascripts/lib/utils/common_utils.js.es6
index 51993bb3420..e3bff2559fd 100644
--- a/app/assets/javascripts/lib/utils/common_utils.js.es6
+++ b/app/assets/javascripts/lib/utils/common_utils.js.es6
@@ -162,6 +162,7 @@
w.gl.utils.getSelectedFragment = () => {
const selection = window.getSelection();
+ if (selection.rangeCount === 0) return null;
const documentFragment = selection.getRangeAt(0).cloneContents();
if (documentFragment.textContent.length === 0) return null;
diff --git a/app/assets/javascripts/shortcuts_issuable.js b/app/assets/javascripts/shortcuts_issuable.js
index 4ef516af8c8..4dcc5ebe28f 100644
--- a/app/assets/javascripts/shortcuts_issuable.js
+++ b/app/assets/javascripts/shortcuts_issuable.js
@@ -39,17 +39,20 @@
}
ShortcutsIssuable.prototype.replyWithSelectedText = function() {
- var quote, replyField, documentFragment, selected, separator;
+ var quote, documentFragment, selected, separator;
+ var replyField = $('.js-main-target-form #note_note');
documentFragment = window.gl.utils.getSelectedFragment();
- if (!documentFragment) return;
+ if (!documentFragment) {
+ replyField.focus();
+ return;
+ }
// If the documentFragment contains more than just Markdown, don't copy as GFM.
if (documentFragment.querySelector('.md, .wiki')) return;
selected = window.gl.CopyAsGFM.nodeToGFM(documentFragment);
- replyField = $('.js-main-target-form #note_note');
if (selected.trim() === "") {
return;
}