Skip to content

fix: Input shrinks to its wrapper past the browser default of size=20#35764

Open
smhigley wants to merge 2 commits intomicrosoft:masterfrom
smhigley:input-size
Open

fix: Input shrinks to its wrapper past the browser default of size=20#35764
smhigley wants to merge 2 commits intomicrosoft:masterfrom
smhigley:input-size

Conversation

@smhigley
Copy link
Contributor

@smhigley smhigley commented Feb 19, 2026

Previous Behavior

This is a little complex since it deals with <input>-specific browser styling around min-width. Input elements have a default size="20" (the html attribute, not our Fluent one), which creates something like a min-width style, but not actually a default min-width, so it is not overridden by our CSS style of min-width: 0. The default behavior is to ensure at least 20 characters are shown, which is something like a minimum width of 150px (which can vary a little per OS, etc.).

This creates a problem where the Fluent Input does not shrink to containers that are both:

  1. smaller than ~150px ish
  2. do not absolutely force their children to shrink

One example is containers with display: grid, which is incidentally the style our Field control uses. So the Input does not shrink with a Field when the Field goes below ~150ish px

Here's a stackblitz from a partner team showing the issue (either zoom, shrink the window, or both to see input grow past the container bounds): https://stackblitz.com/edit/yt5wtcjy?file=index.html

(there is also an ADO a11y issue related to reflow)

New Behavior

From both my memory and the CSS style of min-width: 0, I believe our intention was to make our Fluent Input shrink to any container, no matter how small. I've added size="1" to the inner <input>, so it together with the existing min-width style should allow this for any container.

Related Issue(s)

@smhigley smhigley requested review from a team and dmytrokirpa as code owners February 19, 2026 21:41
@github-actions
Copy link

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.291 MB
322.941 kB
1.291 MB
322.944 kB
7 B
3 B
react-datepicker-compat
DatePicker Compat
225.014 kB
63.584 kB
225.021 kB
63.588 kB
7 B
4 B
react-input
Input
26.246 kB
8.688 kB
26.253 kB
8.692 kB
7 B
4 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
70.397 kB
19.96 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
237.306 kB
68.52 kB
react-components
react-components: FluentProvider & webLightTheme
43.612 kB
14.022 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-timepicker-compat
TimePicker
108.15 kB
35.693 kB
🤖 This report was generated against 15159bafa8fed4f264c0df9f49879e8e28f4cbb3

@github-actions
Copy link

Pull request demo site: URL

@@ -51,3 +51,12 @@ export const WithAppearanceOverride = () => (
</FluentProvider>

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Charts-DonutChart 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic.default.chromium.png 5581 Changed
vr-tests-react-components/DatePicker Compat 11 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/DatePicker Compat.default - Dark Mode.opened.chromium.png 3662 Changed
vr-tests-react-components/DatePicker Compat.default - Dark Mode.rest.chromium.png 4996 Changed
vr-tests-react-components/DatePicker Compat.default - High Contrast.opened.chromium.png 2710 Changed
vr-tests-react-components/DatePicker Compat.default - High Contrast.rest.chromium.png 4253 Changed
vr-tests-react-components/DatePicker Compat.default.opened.chromium.png 9944 Changed
vr-tests-react-components/DatePicker Compat.default.rest.chromium.png 9964 Changed
vr-tests-react-components/DatePicker Compat.Underlined.default.chromium.png 409 Changed
vr-tests-react-components/DatePicker Compat.when rendering inline, it should not render behind relatively positioned elements.default.chromium.png 440 Changed
vr-tests-react-components/DatePicker Compat.showWeekNumbers - Dark Mode.default.chromium.png 474 Changed
vr-tests-react-components/DatePicker Compat.showWeekNumbers - High Contrast.default.chromium.png 787 Changed
vr-tests-react-components/DatePicker Compat.showWeekNumbers.default.chromium.png 440 Changed
vr-tests-react-components/Input Converged 24 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Input Converged.Appearance- filled-darker.hover.chromium.png 135 Changed
vr-tests-react-components/Input Converged.Appearance- filled-lighter.default.chromium.png 121 Changed
vr-tests-react-components/Input Converged.Appearance- outline (default).hover.chromium.png 267 Changed
vr-tests-react-components/Input Converged.Disabled, appearance- filled-lighter.hover.chromium.png 67 Changed
vr-tests-react-components/Input Converged.Disabled, appearance- outline.hover.chromium.png 87 Changed
vr-tests-react-components/Input Converged.Disabled, appearance- underline.focused.chromium.png 64 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- filled-lighter.focused.chromium.png 291 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- filled-darker.hover.chromium.png 339 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- filled-darker.focused.chromium.png 316 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- outline.focused.chromium.png 370 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- underline.focused.chromium.png 313 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- filled-lighter.hover.chromium.png 314 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- outline.hover.chromium.png 337 Changed
vr-tests-react-components/Input Converged.Size- large.default.chromium.png 309 Changed
vr-tests-react-components/Input Converged.Invalid, appearance- underline.hover.chromium.png 217 Changed
vr-tests-react-components/Input Converged.Size- small.default.chromium.png 202 Changed
vr-tests-react-components/Input Converged.With value.hover.chromium.png 208 Changed
vr-tests-react-components/Input Converged.contentAfter.default.chromium.png 275 Changed
vr-tests-react-components/Input Converged.With value.default.chromium.png 195 Changed
vr-tests-react-components/Input Converged.With value.focused.chromium.png 310 Changed
vr-tests-react-components/Input Converged.contentAfter - RTL.default.chromium.png 281 Changed
vr-tests-react-components/Input Converged.contentBefore - RTL.default.chromium.png 255 Changed
vr-tests-react-components/Input Converged.contentBefore.default.chromium.png 254 Changed
vr-tests-react-components/Input Converged.Shrink to wrapper.default.chromium.png 0 Added
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 745 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 609 Changed
vr-tests-react-components/SearchBox Converged 24 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/SearchBox Converged.Appearance- filled-darker.default.chromium.png 7044 Changed
vr-tests-react-components/SearchBox Converged.Appearance- filled-lighter.default.chromium.png 9918 Changed
vr-tests-react-components/SearchBox Converged.Appearance- filled-darker.hover.chromium.png 7019 Changed
vr-tests-react-components/SearchBox Converged.Appearance- filled-lighter.hover.chromium.png 9915 Changed
vr-tests-react-components/SearchBox Converged.Appearance- underline.default.chromium.png 7122 Changed
vr-tests-react-components/SearchBox Converged.Appearance- outline (default).hover.chromium.png 7138 Changed
vr-tests-react-components/SearchBox Converged.Clears value.dismiss clicked.chromium.png 7065 Changed
vr-tests-react-components/SearchBox Converged.Appearance- underline.hover.chromium.png 7165 Changed
vr-tests-react-components/SearchBox Converged.Clears value.input focused.chromium.png 7197 Changed
vr-tests-react-components/SearchBox Converged.Clears value.dismiss focused.chromium.png 7111 Changed
vr-tests-react-components/SearchBox Converged.Disabled, appearance- filled-lighter.hover.chromium.png 9778 Changed
vr-tests-react-components/SearchBox Converged.Disabled, appearance- outline.focused.chromium.png 7218 Changed
vr-tests-react-components/SearchBox Converged.Size- large.default.chromium.png 9382 Changed
vr-tests-react-components/SearchBox Converged.Disabled, appearance- underline.hover.chromium.png 7232 Changed
vr-tests-react-components/SearchBox Converged.Size- small.default.chromium.png 5144 Changed
vr-tests-react-components/SearchBox Converged.Size- small.hover.chromium.png 5152 Changed
vr-tests-react-components/SearchBox Converged.Size- large.hover.chromium.png 9430 Changed
vr-tests-react-components/SearchBox Converged.With custom dismiss - RTL.default.chromium.png 7024 Changed
vr-tests-react-components/SearchBox Converged.WIth contentAfter.hover.chromium.png 7168 Changed
vr-tests-react-components/SearchBox Converged.With custom dismiss.default.chromium.png 7106 Changed
vr-tests-react-components/SearchBox Converged.With custom dismiss - RTL.focused.chromium.png 6930 Changed
vr-tests-react-components/SearchBox Converged.With value.default.chromium.png 7198 Changed
vr-tests-react-components/SearchBox Converged.With custom dismiss.hover.chromium.png 7133 Changed
vr-tests-react-components/SearchBox Converged.With value.hover.chromium.png 7129 Changed
vr-tests-react-components/Shadow DOM 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Shadow DOM.Default.default.chromium.png 306 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png 1319 Changed
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png 658 Changed
vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png 635 Changed

There were 63 duplicate changes discarded. Check the build logs for more information.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments