Skip to content

Commit 7dd710f

Browse files
committed
Fix option list height var bug
1 parent 3e1b6bb commit 7dd710f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/elements/ia-combo-box/ia-combo-box-story.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const styleInputSettings: StyleInputSettings[] = [
3636
},
3737
{
3838
label: 'Dropdown max height',
39-
cssVariable: '--combo-box-list-height',
39+
cssVariable: '--combo-box-list-max-height',
4040
defaultValue: '250px',
4141
inputType: 'text',
4242
},

src/elements/ia-combo-box/ia-combo-box.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,11 +1055,13 @@ export class IAComboBox extends LitElement {
10551055
const usableHeightAbove = mainWidgetRect.top;
10561056
const usableHeightBelow = innerHeight - mainWidgetRect.bottom;
10571057

1058+
const maxHeightVar = `var(--combo-box-list-max-height--)`;
1059+
10581060
const optionsListStyles: Record<string, string> = {
10591061
top: `${mainWidgetRect.bottom + scrollY}px`,
10601062
left: `${mainWidgetRect.left + scrollX}px`,
10611063
width: `var(--combo-box-list-width--, ${mainWidgetRect.width}px)`,
1062-
maxHeight: `${usableHeightBelow}px`,
1064+
maxHeight: `min(${maxHeightVar}, ${usableHeightBelow}px)`,
10631065
};
10641066

10651067
Object.assign(optionsList.style, optionsListStyles);
@@ -1072,7 +1074,7 @@ export class IAComboBox extends LitElement {
10721074
if (overflowingViewport && moreSpaceAbove) {
10731075
optionsList.style.top = 'auto';
10741076
optionsList.style.bottom = `${innerHeight - mainWidgetRect.top - scrollY}px`;
1075-
optionsList.style.maxHeight = `${usableHeightAbove}px`;
1077+
optionsList.style.maxHeight = `min(${maxHeightVar}, ${usableHeightAbove}px)`;
10761078
}
10771079
}, 0);
10781080
}
@@ -1212,7 +1214,7 @@ export class IAComboBox extends LitElement {
12121214
--combo-box-width--: var(--combo-box-width);
12131215
--combo-box-padding--: var(--padding-sm);
12141216
--combo-box-list-width--: var(--combo-box-list-width, unset);
1215-
--combo-box-list-height--: var(--combo-box-list-height, 250px);
1217+
--combo-box-list-max-height--: var(--combo-box-list-max-height, 250px);
12161218
}
12171219
12181220
#container {
@@ -1303,7 +1305,6 @@ export class IAComboBox extends LitElement {
13031305
padding: 0;
13041306
background: white;
13051307
width: var(--combo-box-list-width--);
1306-
height: var(--combo-box-list-height--);
13071308
max-height: 400px;
13081309
box-shadow: 0 0 1px 1px #ddd;
13091310
opacity: 0;

0 commit comments

Comments
 (0)