Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7bf6df84
Commit
7bf6df84
authored
Jan 30, 2017
by
Brian Hall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the reply shortcut to focus the field even without a selection.
parent
b78d06b7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
5 deletions
+21
-5
app/assets/javascripts/lib/utils/common_utils.js.es6
app/assets/javascripts/lib/utils/common_utils.js.es6
+1
-0
app/assets/javascripts/shortcuts_issuable.js
app/assets/javascripts/shortcuts_issuable.js
+6
-3
changelogs/unreleased/empty-selection-reply-shortcut.yml
changelogs/unreleased/empty-selection-reply-shortcut.yml
+4
-0
spec/javascripts/shortcuts_issuable_spec.js
spec/javascripts/shortcuts_issuable_spec.js
+10
-2
No files found.
app/assets/javascripts/lib/utils/common_utils.js.es6
View file @
7bf6df84
...
@@ -162,6 +162,7 @@
...
@@ -162,6 +162,7 @@
w.gl.utils.getSelectedFragment = () => {
w.gl.utils.getSelectedFragment = () => {
const selection = window.getSelection();
const selection = window.getSelection();
if (selection.rangeCount === 0) return null;
const documentFragment = selection.getRangeAt(0).cloneContents();
const documentFragment = selection.getRangeAt(0).cloneContents();
if (documentFragment.textContent.length === 0) return null;
if (documentFragment.textContent.length === 0) return null;
...
...
app/assets/javascripts/shortcuts_issuable.js
View file @
7bf6df84
...
@@ -39,17 +39,20 @@
...
@@ -39,17 +39,20 @@
}
}
ShortcutsIssuable
.
prototype
.
replyWithSelectedText
=
function
()
{
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
();
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 the documentFragment contains more than just Markdown, don't copy as GFM.
if
(
documentFragment
.
querySelector
(
'
.md, .wiki
'
))
return
;
if
(
documentFragment
.
querySelector
(
'
.md, .wiki
'
))
return
;
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
documentFragment
);
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
documentFragment
);
replyField
=
$
(
'
.js-main-target-form #note_note
'
);
if
(
selected
.
trim
()
===
""
)
{
if
(
selected
.
trim
()
===
""
)
{
return
;
return
;
}
}
...
...
changelogs/unreleased/empty-selection-reply-shortcut.yml
0 → 100644
View file @
7bf6df84
---
title
:
Change the reply shortcut to focus the field even without a selection.
merge_request
:
8873
author
:
Brian Hall
spec/javascripts/shortcuts_issuable_spec.js
View file @
7bf6df84
...
@@ -27,11 +27,19 @@
...
@@ -27,11 +27,19 @@
return
this
.
selector
=
'
form.js-main-target-form textarea#note_note
'
;
return
this
.
selector
=
'
form.js-main-target-form textarea#note_note
'
;
});
});
describe
(
'
with empty selection
'
,
function
()
{
describe
(
'
with empty selection
'
,
function
()
{
return
it
(
'
does nothing
'
,
function
()
{
it
(
'
does not return an error
'
,
function
()
{
stubSelection
(
''
);
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
();
return
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
''
);
return
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
''
);
});
});
return
it
(
'
triggers `input`
'
,
function
()
{
var
focused
;
focused
=
false
;
$
(
this
.
selector
).
on
(
'
focus
'
,
function
()
{
return
focused
=
true
;
});
this
.
shortcut
.
replyWithSelectedText
();
return
expect
(
focused
).
toBe
(
true
);
});
});
});
describe
(
'
with any selection
'
,
function
()
{
describe
(
'
with any selection
'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment