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
f0071603
Commit
f0071603
authored
Jun 03, 2021
by
Furkan Ayhan
Committed by
Miguel Rincon
Jun 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle enter action of MR comment form
parent
546267fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
app/assets/javascripts/notes/components/comment_form.vue
app/assets/javascripts/notes/components/comment_form.vue
+9
-2
spec/frontend/notes/components/comment_form_spec.js
spec/frontend/notes/components/comment_form_spec.js
+33
-8
No files found.
app/assets/javascripts/notes/components/comment_form.vue
View file @
f0071603
...
...
@@ -273,6 +273,13 @@ export default {
this
.
toggleIssueState
();
}
},
handleEnter
()
{
if
(
this
.
hasDrafts
)
{
this
.
handleSaveDraft
();
}
else
{
this
.
handleSave
();
}
},
toggleIssueState
()
{
if
(
this
.
isIssue
)
{
// We want to invoke the close/reopen logic in the issue header
...
...
@@ -395,8 +402,8 @@ export default {
:aria-label=
"$options.i18n.comment"
:placeholder=
"$options.i18n.bodyPlaceholder"
@
keydown.up=
"editCurrentUserLastNote()"
@
keydown.meta.enter=
"handle
Save
()"
@
keydown.ctrl.enter=
"handle
Save
()"
@
keydown.meta.enter=
"handle
Enter
()"
@
keydown.ctrl.enter=
"handle
Enter
()"
></textarea>
</
template
>
</markdown-field>
...
...
spec/frontend/notes/components/comment_form_spec.js
View file @
f0071603
...
...
@@ -328,12 +328,13 @@ describe('issue_comment_form component', () => {
mountComponent
({
mountFunction
:
mount
});
});
describe
(
'
when no draft exists
'
,
()
=>
{
it
(
'
should save note when cmd+enter is pressed
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSave
'
);
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
metaKey
:
true
});
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalledWith
();
});
it
(
'
should save note when ctrl+enter is pressed
'
,
()
=>
{
...
...
@@ -341,7 +342,31 @@ describe('issue_comment_form component', () => {
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
ctrlKey
:
true
});
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
handleSave
).
toHaveBeenCalledWith
();
});
});
describe
(
'
when a draft exists
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
registerModule
(
'
batchComments
'
,
batchComments
());
store
.
state
.
batchComments
.
drafts
=
[{
note
:
'
A
'
}];
});
it
(
'
should save note draft when cmd+enter is pressed
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSaveDraft
'
);
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
metaKey
:
true
});
expect
(
wrapper
.
vm
.
handleSaveDraft
).
toHaveBeenCalledWith
();
});
it
(
'
should save note draft when ctrl+enter is pressed
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
handleSaveDraft
'
);
findTextArea
().
trigger
(
'
keydown.enter
'
,
{
ctrlKey
:
true
});
expect
(
wrapper
.
vm
.
handleSaveDraft
).
toHaveBeenCalledWith
();
});
});
});
});
...
...
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