diff --git a/src/bundle/Resources/public/js/scripts/core/custom.dropdown.js b/src/bundle/Resources/public/js/scripts/core/custom.dropdown.js index cc5f7a30ec..c2d7c86801 100644 --- a/src/bundle/Resources/public/js/scripts/core/custom.dropdown.js +++ b/src/bundle/Resources/public/js/scripts/core/custom.dropdown.js @@ -131,16 +131,21 @@ this.sourceInput.dispatchEvent(new CustomEvent(EVENT_VALUE_CHANGED)); } - getItemsContainerHeight(isItemsContainerTop) { + getItemsContainerHeight(isItemsContainerAbove) { const DROPDOWN_MARGIN = 16; + const SELECTOR_MODAL = '.modal[aria-modal=true]'; + const documentElementHeight = doc.documentElement.getBoundingClientRect().height; + const itemsContainerTop = this.itemsContainer.getBoundingClientRect().top; - if (isItemsContainerTop) { + if (isItemsContainerAbove) { return this.container.querySelector(SELECTOR_SELECTION_INFO).getBoundingClientRect().top - DROPDOWN_MARGIN; } - return ( - document.documentElement.getBoundingClientRect().height - this.itemsContainer.getBoundingClientRect().top - DROPDOWN_MARGIN - ); + if (this.itemsContainer.closest(SELECTOR_MODAL)) { + return itemsContainerTop - DROPDOWN_MARGIN; + } + + return documentElementHeight - itemsContainerTop - DROPDOWN_MARGIN; } onInputClick(event) { @@ -156,10 +161,10 @@ if (isListHidden) { const viewportHeight = window.innerHeight || document.documentElement.clientHeight; const { top } = this.itemsContainer.getBoundingClientRect(); - const isItemsContainerTop = top + ITEMS_LIST_MAX_HEIGHT > viewportHeight; - const itemsListMethodName = isItemsContainerTop ? 'add' : 'remove'; + const isItemsContainerAbove = top + ITEMS_LIST_MAX_HEIGHT > viewportHeight; + const itemsListMethodName = isItemsContainerAbove ? 'add' : 'remove'; - this.itemsContainer.style['max-height'] = `${this.getItemsContainerHeight(isItemsContainerTop)}px`; + this.itemsContainer.style['max-height'] = `${this.getItemsContainerHeight(isItemsContainerAbove)}px`; this.itemsContainer.classList[itemsListMethodName](CLASS_ITEMS_POSITION_TOP); }