@@ -75,6 +75,7 @@ export class MultiSelectFilterComponent<T extends EntityWithId> implements OnIni
7575 replaceItemsSubscription ?: Subscription
7676 replaceSelectedItemsSubscription ?: Subscription
7777 clearItemsSubscription ?: Subscription
78+ popupSubscription ?: Subscription
7879 private resizeTimer ?: ReturnType < typeof setTimeout >
7980
8081 focusedSelectedItemIndex ?: number
@@ -137,6 +138,11 @@ export class MultiSelectFilterComponent<T extends EntityWithId> implements OnIni
137138 if ( this . config . initialValues != undefined ) {
138139 this . replaceSelectedItems ( this . config . initialValues )
139140 }
141+ this . popupSubscription = this . dataService . onButtonPopupOpen$ . subscribe ( ( source => {
142+ if ( source !== this && this . formVisible ) {
143+ this . close ( )
144+ }
145+ } ) )
140146 this . ready . emit ( this . config . name )
141147 }
142148
@@ -254,6 +260,7 @@ export class MultiSelectFilterComponent<T extends EntityWithId> implements OnIni
254260 if ( this . replaceItemsSubscription ) this . replaceItemsSubscription . unsubscribe ( )
255261 if ( this . replaceSelectedItemsSubscription ) this . replaceSelectedItemsSubscription . unsubscribe ( )
256262 if ( this . clearItemsSubscription ) this . clearItemsSubscription . unsubscribe ( )
263+ if ( this . popupSubscription ) this . popupSubscription . unsubscribe ( )
257264 clearTimeout ( this . resizeTimer )
258265 }
259266
@@ -445,6 +452,7 @@ export class MultiSelectFilterComponent<T extends EntityWithId> implements OnIni
445452 if ( this . formVisible ) {
446453 this . close ( )
447454 } else {
455+ this . dataService . signalButtonPopup ( this )
448456 this . formVisible = true
449457 this . formPositioned = false
450458 this . updateCheckFlag ( )
@@ -501,6 +509,9 @@ export class MultiSelectFilterComponent<T extends EntityWithId> implements OnIni
501509 }
502510
503511 private adjustHeight ( minHeight : number , onPositioned ?: ( ) => void ) {
512+ // The 2px gap matches ng-bootstrap's dropdown default Popper offset, and the same gap used
513+ // by the checkbox-option-panel component's popup positioning.
514+ const gap = 2 ;
504515 this . availableItemsHeight = minHeight ;
505516 setTimeout ( ( ) => {
506517 if ( this . filterFormElement && this . filterControlElement ) {
@@ -526,16 +537,16 @@ export class MultiSelectFilterComponent<T extends EntityWithId> implements OnIni
526537 controlTop = 0
527538 }
528539 const maxHeight = window . innerHeight
529- const formBottom = controlBottom + formHeight
530- const formTop = controlTop - formHeight
540+ const formBottom = ( controlBottom ?? 0 ) + gap + formHeight
541+ const formTop = controlTop - gap - formHeight
531542 fitsBottom = formBottom <= maxHeight
532543 fitsTop = formTop > 0
533544 if ( fitsBottom ) {
534- this . formTop = controlHeight
545+ this . formTop = controlHeight + gap
535546 this . formPositioned = true
536547 onPositioned ?.( )
537548 } else if ( fitsTop ) {
538- this . formTop = formHeight * - 1
549+ this . formTop = ( formHeight + gap ) * - 1
539550 this . formPositioned = true
540551 onPositioned ?.( )
541552 } else {
0 commit comments