Skip to content

[select] Check for 100% max-height style#3749

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:fix/select-max-height-align
Jan 15, 2026
Merged

[select] Check for 100% max-height style#3749
atomiks merged 1 commit into
mui:masterfrom
atomiks:fix/select-max-height-align

Conversation

@atomiks

@atomiks atomiks commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

The "old" JSX structure without <Select.List> regressed from #3573, but this is still supported. The max-height was calculated as 100% due to the inline style, which we can check for.

https://deploy-preview-3749--base-ui.netlify.app/experiments/long-select

@atomiks atomiks added component: select Changes related to the select component. type: regression A bug, but worse, it used to behave as expected. labels Jan 15, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jan 15, 2026

Copy link
Copy Markdown
  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@3749
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3749
    

commit: 2ead2c6

@mui-bot

mui-bot commented Jan 15, 2026

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+32B(+0.01%) 🔺+18B(+0.01%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jan 15, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 2ead2c6
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6968d8fc79dda500082ee25a
😎 Deploy Preview https://deploy-preview-3749--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks marked this pull request as ready for review January 15, 2026 11:46
@greptile-apps

greptile-apps Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a regression in the select component's alignItemWithTrigger feature for the "old" JSX structure (without Select.List). The issue was introduced in PR #3573.

Root Cause:
When alignItemWithTrigger is active, line 316 sets an inline style popupElement.style.height = '100%'. The getMaxPopupHeight function was calling parseFloat() on this value, which returned NaN for the string '100%'.

Solution:
The fix explicitly checks if maxHeightStyle === '100%' and returns Infinity in that case, which correctly indicates no maximum height constraint. This ensures proper height calculations for both JSX structures (with and without Select.List).

Changes:

  • Modified getMaxPopupHeight to accept CSSStyleDeclaration instead of HTMLElement
  • Added explicit check for '100%' value before parsing
  • Updated both call sites to pass computed styles instead of element

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is a targeted, well-reasoned change that addresses a specific regression. The logic is sound: explicitly handling the '100%' case before parseFloat prevents NaN issues. The change maintains backward compatibility with both JSX structures (with/without Select.List), and the fix aligns with the component's existing inline style usage on line 316.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/select/popup/SelectPopup.tsx Fixed regression for old JSX structure without Select.List by checking for 100% max-height inline style

Sequence Diagram

sequenceDiagram
    participant User
    participant SelectPopup
    participant getMaxPopupHeight
    participant Browser

    User->>SelectPopup: Open select with alignItemWithTrigger active
    SelectPopup->>Browser: Set popupElement.style.height = '100%'
    SelectPopup->>Browser: getComputedStyle(popupRef.current)
    Browser-->>SelectPopup: CSSStyleDeclaration
    SelectPopup->>getMaxPopupHeight: Call with popupStyles
    getMaxPopupHeight->>getMaxPopupHeight: Check if maxHeightStyle === '100%'
    alt maxHeightStyle is '100%'
        getMaxPopupHeight-->>SelectPopup: Return Infinity
    else maxHeightStyle is numeric
        getMaxPopupHeight->>getMaxPopupHeight: parseFloat(maxHeightStyle)
        getMaxPopupHeight-->>SelectPopup: Return parsed value or Infinity
    end
    SelectPopup->>SelectPopup: Calculate viewportHeight using maxPopupHeight
    SelectPopup->>Browser: Apply positioning and height styles
Loading

@atomiks atomiks added the internal Behind-the-scenes enhancement. Formerly called “core”. label Jan 15, 2026
@atomiks atomiks force-pushed the fix/select-max-height-align branch from f14960d to 2ead2c6 Compare January 15, 2026 12:09
@atomiks atomiks merged commit 66c90eb into mui:master Jan 15, 2026
23 checks passed
@atomiks atomiks deleted the fix/select-max-height-align branch January 15, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: select Changes related to the select component. internal Behind-the-scenes enhancement. Formerly called “core”. type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants