summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/file_template_selector.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/assets/javascripts/blob/file_template_selector.js
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
downloadgitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/assets/javascripts/blob/file_template_selector.js')
-rw-r--r--app/assets/javascripts/blob/file_template_selector.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/app/assets/javascripts/blob/file_template_selector.js b/app/assets/javascripts/blob/file_template_selector.js
index a5c8050b772..e02217d0deb 100644
--- a/app/assets/javascripts/blob/file_template_selector.js
+++ b/app/assets/javascripts/blob/file_template_selector.js
@@ -19,6 +19,17 @@ export default class FileTemplateSelector {
this.$dropdownToggleText = this.$wrapper.find('.dropdown-toggle-text');
this.initDropdown();
+ this.selectInitialTemplate();
+ }
+
+ selectInitialTemplate() {
+ const template = this.$dropdown.data('selected');
+
+ if (!template) {
+ return;
+ }
+
+ this.mediator.selectTemplateFile(this, template);
}
show() {
@@ -27,6 +38,19 @@ export default class FileTemplateSelector {
}
this.$wrapper.removeClass('hidden');
+
+ /**
+ * We set the focus on the dropdown that was just shown. This is done so that, after selecting
+ * a template type, the template selector immediately receives the focus.
+ * This improves the UX of the tour as the suggest_gitlab_ci_yml popover requires its target to
+ * be have the focus to appear. This way, users don't have to interact with the template
+ * selector to actually see the first hint: it is shown as soon as the selector becomes visible.
+ * We also need a timeout here, otherwise the template type selector gets stuck and can not be
+ * closed anymore.
+ */
+ setTimeout(() => {
+ this.$dropdown.focus();
+ }, 0);
}
hide() {
@@ -36,7 +60,7 @@ export default class FileTemplateSelector {
}
isHidden() {
- return this.$wrapper.hasClass('hidden');
+ return !this.$wrapper || this.$wrapper.hasClass('hidden');
}
getToggleText() {