Commit 178514e0 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch...

Merge branch '56328-frequent-items-initialisations-can-be-optimised-and-deferred-in-idlecallback' into 'master'

Resolve "Frequent Items Initialisations can be optimised and deferred in idleCallback"

Closes #56328

See merge request gitlab-org/gitlab-ce!24401
parents 33a6f237 e51a0df3
...@@ -47,6 +47,12 @@ export default { ...@@ -47,6 +47,12 @@ export default {
} }
eventHub.$on(`${this.namespace}-dropdownOpen`, this.dropdownOpenHandler); eventHub.$on(`${this.namespace}-dropdownOpen`, this.dropdownOpenHandler);
// As we init it through requestIdleCallback it could be that the dropdown is already open
const namespaceDropdown = document.getElementById(`nav-${this.namespace}-dropdown`);
if (namespaceDropdown && namespaceDropdown.classList.contains('show')) {
this.dropdownOpenHandler();
}
}, },
beforeDestroy() { beforeDestroy() {
eventHub.$off(`${this.namespace}-dropdownOpen`, this.dropdownOpenHandler); eventHub.$off(`${this.namespace}-dropdownOpen`, this.dropdownOpenHandler);
......
...@@ -17,7 +17,7 @@ const frequentItemDropdowns = [ ...@@ -17,7 +17,7 @@ const frequentItemDropdowns = [
}, },
]; ];
document.addEventListener('DOMContentLoaded', () => { const initFrequentItemDropdowns = () => {
frequentItemDropdowns.forEach(dropdown => { frequentItemDropdowns.forEach(dropdown => {
const { namespace, key } = dropdown; const { namespace, key } = dropdown;
const el = document.getElementById(`js-${namespace}-dropdown`); const el = document.getElementById(`js-${namespace}-dropdown`);
...@@ -66,4 +66,8 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -66,4 +66,8 @@ document.addEventListener('DOMContentLoaded', () => {
}, },
}); });
}); });
};
document.addEventListener('DOMContentLoaded', () => {
requestIdleCallback(initFrequentItemDropdowns);
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment