Updates SSH key title after pasting key

Previously it was listening for focusout, it now listens for blur &
paste events

Closes #28436
This commit is contained in:
Phil Hughes 2017-02-23 17:48:44 +00:00
parent d6f18f8e19
commit e42169c28e
3 changed files with 9 additions and 4 deletions

View file

@ -84,13 +84,14 @@
}
$(function() {
$(document).on('focusout.ssh_key', '#key_key', function() {
$(document).on('input.ssh_key', '#key_key', function() {
const $title = $('#key_title');
const comment = $(this).val().match(/^\S+ \S+ (.+)\n?$/);
if (comment && comment.length > 1 && $title.val() === '') {
// Extract the SSH Key title from its comment
if (comment && comment.length > 1) {
return $title.val(comment[1]).change();
}
// Extract the SSH Key title from its comment
});
if (global.utils.getPagePath() === 'profiles') {
return new Profile();

View file

@ -0,0 +1,4 @@
---
title: SSH key field updates title after pasting key
merge_request:
author:

View file

@ -15,7 +15,7 @@ feature 'Profile > SSH Keys', feature: true do
scenario 'auto-populates the title', js: true do
fill_in('Key', with: attributes_for(:key).fetch(:key))
expect(find_field('Title').value).to eq 'dummy@gitlab.com'
expect(page).to have_field("Title", with: "dummy@gitlab.com")
end
scenario 'saves the new key' do