diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-04 18:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-04 18:09:26 +0300 |
commit | cad0cc33957b0ea82afb34836e42419bea5a99b9 (patch) | |
tree | 55f30a2cd2e8fde03e39c77b2fe4a4a3e2a1bb93 /app/assets/javascripts/projects | |
parent | 13f961dce9cbed0a684d694fb1cb9d85946e3be4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/projects')
-rw-r--r-- | app/assets/javascripts/projects/project_new.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/app/assets/javascripts/projects/project_new.js b/app/assets/javascripts/projects/project_new.js index fbef51b43b2..3e1c471f015 100644 --- a/app/assets/javascripts/projects/project_new.js +++ b/app/assets/javascripts/projects/project_new.js @@ -3,6 +3,7 @@ import { debounce } from 'lodash'; import DEFAULT_PROJECT_TEMPLATES from 'ee_else_ce/projects/default_project_templates'; import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '../lib/utils/constants'; +import { ENTER_KEY } from '../lib/utils/keys'; import axios from '../lib/utils/axios_utils'; import { convertToTitleCase, @@ -182,7 +183,11 @@ const bindEvents = () => { $projectTemplateButtons.addClass('hidden'); $projectFieldsForm.addClass('selected'); $selectedIcon.empty(); - const value = $(this).val(); + + const $selectedTemplate = $(this); + $selectedTemplate.prop('checked', true); + + const value = $selectedTemplate.val(); const selectedTemplate = DEFAULT_PROJECT_TEMPLATES[value]; $selectedTemplateText.text(selectedTemplate.text); @@ -194,7 +199,21 @@ const bindEvents = () => { setProjectNamePathHandlers($activeTabProjectName, $activeTabProjectPath); } - $useTemplateBtn.on('change', chooseTemplate); + function toggleActiveClassOnLabel(event) { + const $label = $(event.target).parent(); + $label.toggleClass('active'); + } + + function chooseTemplateOnEnter(event) { + if (event.code === ENTER_KEY) { + chooseTemplate.call(this); + } + } + + $useTemplateBtn.on('click', chooseTemplate); + + $useTemplateBtn.on('focus focusout', toggleActiveClassOnLabel); + $useTemplateBtn.on('keypress', chooseTemplateOnEnter); $changeTemplateBtn.on('click', () => { $projectTemplateButtons.removeClass('hidden'); |