Skip to content

Commit d307183

Browse files
fix(Select): align responsive popover max-width with ComboBox/Input pattern
Use the same max-width pattern as ComboBox and Input: - If the component width in rem exceeds 40, cap max-width at the component's own pixel width (preventing the picker from growing wider than the control) - Otherwise fall back to the 40rem default cap This replaces the previous flat 100rem value and matches the established pattern used in ComboBox.ts and Input.ts. Updated Cypress tests to reflect the dynamic max-width logic: - Narrow select (200px) -> expects max-width: 40rem - Wide select (1000px) -> expects max-width in px matching the component width
1 parent af4eb20 commit d307183

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

packages/main/cypress/specs/Select.cy.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,11 +1971,11 @@ describe("Select - active/down state", () => {
19711971
});
19721972

19731973
describe("Select - popover max-width", () => {
1974-
it("applies default max-width of 100rem to the responsive popover when an option has very long text", () => {
1974+
it("applies a max-width of 40rem to the responsive popover when the select is narrow and an option has very long text", () => {
19751975
const longText = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. ".repeat(5);
19761976

19771977
cy.mount(
1978-
<Select>
1978+
<Select style="width: 200px;">
19791979
<Option value="desktop" icon="laptop">{longText}</Option>
19801980
<Option value="short">Short option</Option>
19811981
</Select>
@@ -1985,32 +1985,33 @@ describe("Select - popover max-width", () => {
19851985
cy.get("[ui5-select]").realClick();
19861986
cy.get("[ui5-select]").should("have.attr", "opened");
19871987

1988-
// The responsive popover should have max-width capped at 100rem
1988+
// When the select offsetWidth / remSize <= 40, max-width should be 40rem
19891989
cy.get("[ui5-select]")
19901990
.shadow()
19911991
.find("[ui5-responsive-popover]")
19921992
.should($el => {
19931993
const maxWidth = $el[0].style.maxWidth;
1994-
expect(maxWidth).to.equal("100rem");
1994+
expect(maxWidth).to.equal("40rem");
19951995
});
19961996
});
19971997

1998-
it("ensures the popover width does not exceed 100rem style property by default", () => {
1998+
it("caps max-width to the component's own width in pixels when the select is wider than 40rem", () => {
19991999
cy.mount(
2000-
<Select>
2000+
<Select style="width: 1000px;">
20012001
<Option value="short">Short</Option>
20022002
</Select>
20032003
);
20042004

20052005
cy.get("[ui5-select]").realClick();
20062006
cy.get("[ui5-select]").should("have.attr", "opened");
20072007

2008+
// When offsetWidth / remSize > 40, max-width should be the component's width in px
20082009
cy.get("[ui5-select]")
20092010
.shadow()
20102011
.find("[ui5-responsive-popover]")
2011-
.should($el => {
2012-
const maxWidth = $el[0].style.maxWidth;
2013-
expect(maxWidth).to.equal("100rem");
2012+
.then($popover => {
2013+
const maxWidth = $popover[0].style.maxWidth;
2014+
expect(maxWidth).to.match(/^\d+px$/);
20142015
});
20152016
});
20162017
});

packages/main/src/Select.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ class Select extends UI5Element implements IFormInputElement {
10941094
}
10951095

10961096
get styles() {
1097+
const remSizeInPx = parseInt(getComputedStyle(document.documentElement).fontSize);
10971098
return {
10981099
popoverHeader: {
10991100
"display": "block",
@@ -1105,7 +1106,7 @@ class Select extends UI5Element implements IFormInputElement {
11051106
},
11061107
responsivePopover: {
11071108
"min-width": `${this.offsetWidth}px`,
1108-
"max-width": "100rem",
1109+
"max-width": (this.offsetWidth / remSizeInPx) > 40 ? `${this.offsetWidth}px` : "40rem",
11091110
},
11101111
};
11111112
}

0 commit comments

Comments
 (0)