Skip to content

[TextField] Fix Safari outlined notch expansion in flex layouts#48566

Open
maxmorlocke wants to merge 3 commits into
mui:masterfrom
maxmorlocke:fix-ios-notch-issue
Open

[TextField] Fix Safari outlined notch expansion in flex layouts#48566
maxmorlocke wants to merge 3 commits into
mui:masterfrom
maxmorlocke:fix-ios-notch-issue

Conversation

@maxmorlocke
Copy link
Copy Markdown

@maxmorlocke maxmorlocke commented May 23, 2026

This fixes a Safari/WebKit rendering bug where the outlined TextField notch fails to expand correctly in flex layouts (commonly reproduced with Stack), causing the floating label to overlap the top border.

The root cause is WebKit’s handling of percentage max-width on legend inside fieldset in this layout scenario. To my knowledge, this:

I updated OutlinedInput notch expansion style to avoid percentage max-width in the notched state ('100%' maxWidth: '100%' → 'none'). Using this approach keeps behavior consistent across browsers while specifically addressing Safari/WebKit and does not rely on any hardcoded values for width and should not change behavior.

I added a test that reproduces this flex layout scenario and asserts the notch expands on focus. I also added an e2e test on this scenario. These tests (and any tests that failed due to this change) now test on behavior, not on a strictly computed style. I find this makes for more robust tests, but I am happy to change if this is problematic.

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 23, 2026

Deploy preview

https://deploy-preview-48566--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) ▼-1B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

@mj12albert mj12albert added the scope: text field Changes related to the text field. label May 26, 2026
Copy link
Copy Markdown
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, found one issue

style: {
maxWidth: '100%',
// Safari: avoid percentage max-width on <legend> inside <fieldset> in flex layouts.
maxWidth: 'none',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the now unlimited-width <legend> is visually clipped by it's enclosing <fieldset>, the scroll dimensions of the component is changed and could cause unexpected scrollbars when the layout is narrow:

<Box sx={{ width: 220, overflowX: 'auto' }}>
  <TextField
    label="This label is intentionally too long for the outlined input widt…"
    defaultValue="Hello world"
    variant="outlined"
    sx={{ width: 195 }}
  />
</Box>
Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch and thanks for the feedback. Since this has gone through a few iterations over the last couple of years, I'm going to try to make an adjustment to how we calculate the notch's width using a ResizeObserver similar to select/autocomplete's width calculations. This is less ideal, but follows an established pattern. I hope to have an update within the next day or three.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: text field Changes related to the text field.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[text field] Visual bug on outlined label in Safari Display glitch when using multiline in TextField

2 participants