@porscheinformatik/clr-addons 15.2.0 → 15.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dropdown/clr-dropdown-overflow.directive.d.ts +5 -3
- package/esm2020/dropdown/clr-dropdown-overflow.directive.mjs +24 -11
- package/fesm2015/clr-addons.mjs +22 -9
- package/fesm2015/clr-addons.mjs.map +1 -1
- package/fesm2020/clr-addons.mjs +22 -9
- package/fesm2020/clr-addons.mjs.map +1 -1
- package/package.json +1 -1
package/fesm2020/clr-addons.mjs
CHANGED
|
@@ -636,7 +636,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImpor
|
|
|
636
636
|
}] });
|
|
637
637
|
|
|
638
638
|
/*
|
|
639
|
-
* Copyright (c) 2018-
|
|
639
|
+
* Copyright (c) 2018-2023 Porsche Informatik. All Rights Reserved.
|
|
640
640
|
* This software is released under MIT license.
|
|
641
641
|
* The full license information can be found in LICENSE in the root directory of this project.
|
|
642
642
|
*/
|
|
@@ -646,8 +646,10 @@ class ClrDropdownOverflowDirective {
|
|
|
646
646
|
this.defaultItemMinHeightRem = 1.5;
|
|
647
647
|
this.marginBottomRem = 0.1;
|
|
648
648
|
this.destroy$ = new Subject();
|
|
649
|
+
this.alreadyChecked = false;
|
|
650
|
+
this.heightFix = 27;
|
|
649
651
|
}
|
|
650
|
-
|
|
652
|
+
ngAfterContentChecked() {
|
|
651
653
|
// first trigger manually because the subscription lower only triggers after first change
|
|
652
654
|
if (!this.nestedDropdownChildren?.length) {
|
|
653
655
|
this.applyDropdownOverflowStyles();
|
|
@@ -669,14 +671,25 @@ class ClrDropdownOverflowDirective {
|
|
|
669
671
|
applyDropdownOverflowStyles() {
|
|
670
672
|
// the vertical position of our element in the current window
|
|
671
673
|
const y = this.elRef.nativeElement.getBoundingClientRect().y;
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
item
|
|
674
|
+
if (y !== 0 && !this.alreadyChecked) {
|
|
675
|
+
const itemMinHeightPx = this.getItemMinHeight(this.clrDropdownMenuItemMinHeight);
|
|
676
|
+
// see https://stackoverflow.com/questions/22754315/for-loop-for-htmlcollection-elements
|
|
677
|
+
for (const item of this.getAllChildDropdownMenuItems()) {
|
|
678
|
+
item.style.minHeight = itemMinHeightPx + 'px';
|
|
679
|
+
}
|
|
680
|
+
let height = 0;
|
|
681
|
+
if (y + this.heightFix < window.innerHeight - y) {
|
|
682
|
+
height = window.innerHeight - y - this.heightFix;
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
height = window.innerHeight - y;
|
|
686
|
+
}
|
|
687
|
+
this.elRef.nativeElement.style.maxHeight =
|
|
688
|
+
this.getMenuMaxHeight(this.clrDropdownMenuMaxHeight, height - this.convertRemToPixels(this.marginBottomRem)) +
|
|
689
|
+
'px';
|
|
690
|
+
this.elRef.nativeElement.style.overflowY = 'auto';
|
|
691
|
+
this.alreadyChecked = true;
|
|
676
692
|
}
|
|
677
|
-
this.elRef.nativeElement.style.maxHeight =
|
|
678
|
-
this.getMenuMaxHeight(this.clrDropdownMenuMaxHeight, window.innerHeight - y - this.convertRemToPixels(this.marginBottomRem)) + 'px';
|
|
679
|
-
this.elRef.nativeElement.style.overflowY = 'auto';
|
|
680
693
|
}
|
|
681
694
|
removeDropdownOverflowStyles() {
|
|
682
695
|
for (const item of this.getAllChildDropdownMenuItems()) {
|