summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-02-23 17:48:44 +0000
committerPhil Hughes <me@iamphill.com>2017-02-24 16:46:13 +0000
commit819fd96d1aee35b6fc50d39f94e97f45d1d99733 (patch)
treed8856dd89d0c73add219d644bbba27a338a895fd
parentd6f18f8e1989aac4b96ad377f854cf2724f77c19 (diff)
downloadgitlab-ce-819fd96d1aee35b6fc50d39f94e97f45d1d99733.tar.gz
Updates SSH key title after pasting key
Previously it was listening for focusout, it now listens for blur & paste events Closes #28436
-rw-r--r--app/assets/javascripts/profile/profile.js.es618
-rw-r--r--changelogs/unreleased/ssh-key-paste.yml4
2 files changed, 15 insertions, 7 deletions
diff --git a/app/assets/javascripts/profile/profile.js.es6 b/app/assets/javascripts/profile/profile.js.es6
index 81374296522..af86d138c2f 100644
--- a/app/assets/javascripts/profile/profile.js.es6
+++ b/app/assets/javascripts/profile/profile.js.es6
@@ -84,13 +84,17 @@
}
$(function() {
- $(document).on('focusout.ssh_key', '#key_key', function() {
- const $title = $('#key_title');
- const comment = $(this).val().match(/^\S+ \S+ (.+)\n?$/);
- if (comment && comment.length > 1 && $title.val() === '') {
- return $title.val(comment[1]).change();
- }
- // Extract the SSH Key title from its comment
+ $(document).on('blur.ssh_key paste.ssh_key', '#key_key', function() {
+ // Need to wait for 100ms for the pasted value to update .val()
+ setTimeout(() => {
+ const $title = $('#key_title');
+ const comment = $(this).val().match(/^\S+ \S+ (.+)\n?$/);
+
+ // Extract the SSH Key title from its comment
+ if (comment && comment.length > 1) {
+ return $title.val(comment[1]).change();
+ }
+ }, 100);
});
if (global.utils.getPagePath() === 'profiles') {
return new Profile();
diff --git a/changelogs/unreleased/ssh-key-paste.yml b/changelogs/unreleased/ssh-key-paste.yml
new file mode 100644
index 00000000000..1e34ef60f6e
--- /dev/null
+++ b/changelogs/unreleased/ssh-key-paste.yml
@@ -0,0 +1,4 @@
+---
+title: SSH key field updates title after pasting key
+merge_request:
+author: