Skip to content

Commit 56540fa

Browse files
committed
Minor style fixes
1 parent acd83b4 commit 56540fa

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

gitb-ui/ui/src/app/components/checkbox-option-panel/checkbox-option-panel.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ export class CheckboxOptionPanelComponent implements OnInit, OnDestroy, CheckBox
196196
const popup = this.containerDiv.firstElementChild as HTMLElement;
197197
if (!popup) return;
198198
if (this.placement == 'left') {
199+
// The 2px gap matches ng-bootstrap's dropdown default Popper offset, kept consistent with
200+
// the 'bottom' placement's gap below.
201+
const gap = 2;
199202
const popupHeight = popup.offsetHeight;
200203
let top = btnRect.top + scrollY;
201204
if (btnRect.top + popupHeight > window.innerHeight) {
@@ -206,7 +209,7 @@ export class CheckboxOptionPanelComponent implements OnInit, OnDestroy, CheckBox
206209
}
207210
}
208211
popup.style.top = `${top}px`;
209-
popup.style.left = `${btnRect.left + scrollX - popup.offsetWidth}px`;
212+
popup.style.left = `${btnRect.left + scrollX - popup.offsetWidth - gap}px`;
210213
} else {
211214
// Same flip-if-no-room approach as the 'left' placement above, but along the vertical axis:
212215
// open below the button by default, flipping to open above it if there isn't enough room

gitb-ui/ui/src/app/components/multi-select-filter/multi-select-filter.component.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)