diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/assets/javascripts/behaviors | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/assets/javascripts/behaviors')
-rw-r--r-- | app/assets/javascripts/behaviors/select2.js | 33 | ||||
-rw-r--r-- | app/assets/javascripts/behaviors/shortcuts/shortcuts.js | 1 |
2 files changed, 21 insertions, 13 deletions
diff --git a/app/assets/javascripts/behaviors/select2.js b/app/assets/javascripts/behaviors/select2.js index 37b75bb5e56..1f222d8c1f6 100644 --- a/app/assets/javascripts/behaviors/select2.js +++ b/app/assets/javascripts/behaviors/select2.js @@ -1,22 +1,29 @@ import $ from 'jquery'; +import { loadCSSFile } from '../lib/utils/css_utils'; export default () => { - if ($('select.select2').length) { + const $select2Elements = $('select.select2'); + if ($select2Elements.length) { import(/* webpackChunkName: 'select2' */ 'select2/select2') .then(() => { - $('select.select2').select2({ - width: 'resolve', - minimumResultsForSearch: 10, - dropdownAutoWidth: true, - }); + // eslint-disable-next-line promise/no-nesting + loadCSSFile(gon.select2_css_path) + .then(() => { + $select2Elements.select2({ + width: 'resolve', + minimumResultsForSearch: 10, + dropdownAutoWidth: true, + }); - // Close select2 on escape - $('.js-select2').on('select2-close', () => { - setTimeout(() => { - $('.select2-container-active').removeClass('select2-container-active'); - $(':focus').blur(); - }, 1); - }); + // Close select2 on escape + $('.js-select2').on('select2-close', () => { + requestAnimationFrame(() => { + $('.select2-container-active').removeClass('select2-container-active'); + $(':focus').blur(); + }); + }); + }) + .catch(() => {}); }) .catch(() => {}); } diff --git a/app/assets/javascripts/behaviors/shortcuts/shortcuts.js b/app/assets/javascripts/behaviors/shortcuts/shortcuts.js index a53150f8d61..c0f67923191 100644 --- a/app/assets/javascripts/behaviors/shortcuts/shortcuts.js +++ b/app/assets/javascripts/behaviors/shortcuts/shortcuts.js @@ -97,6 +97,7 @@ export default class Shortcuts { e.preventDefault(); }); + // eslint-disable-next-line @gitlab/no-global-event-off $('.js-shortcuts-modal-trigger') .off('click') .on('click', this.onToggleHelp); |