Skip to content

Commit

Permalink
Mount overlay layer if it needed on getOverlayEl
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Dec 27, 2024
1 parent b5ee9d3 commit 89707f9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/composables/_useOverlay/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isNuxtServerSideRendering } from '../../utils';

const OVERLAY_EL_ID = 'k-overlay';

/**
Expand Down Expand Up @@ -41,17 +43,16 @@ export default function _useOverlay() {
* @returns {HTMLElement} The overlay container element #k-overlay
*/
function getOverlayEl() {
if (isNuxtServerSideRendering()) {
return;
}
// do not query DOM for performance reasons
const overlayEl = window.overlayEl;
// unlikely to happen, but just in case
if (!overlayEl) {
// eslint-disable-next-line no-console
console.error(
'[KDS] The overlay container element #k-overlay is missing. KDS initialization failed?',
);
return;
mountOverlay();
}
return overlayEl;
return window.overlayEl;
}

return {
Expand Down

0 comments on commit 89707f9

Please sign in to comment.