Skip to content

Conversation

@behowell
Copy link
Contributor

@behowell behowell commented Mar 31, 2023

Previous Behavior

Field reads and modifies the props of its child elements, in order to set up the aria-labelledby, etc. associations between the control and the labels in the Field.

This works fine in common, simple cases where the control is the direct child of the field. However, some form validation libraries require inserting a React component around the control, as is the case with #27202. This component interferes with the prop setting approach that Field was using.

New Behavior

  • Create FieldContext to pass information about the Field to its child elements.
  • Add utility function useFieldControlProps_unstable for controls to use to merge field props from the context.
  • Hook up FieldContext to form controls in the library.
  • Field no longer reads or modifies props of its child element.

Related Issue(s)

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 31, 2023

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-checkbox
Checkbox
36.067 kB
10.856 kB
37.02 kB
11.255 kB
953 B
399 B
react-combobox
Combobox (including child components)
88.743 kB
28.107 kB
89.718 kB
28.49 kB
975 B
383 B
react-combobox
Dropdown (including child components)
87.441 kB
27.855 kB
88.402 kB
28.217 kB
961 B
362 B
react-datepicker-compat
DatePicker Compat
250.208 kB
66.95 kB
251.272 kB
67.329 kB
1.064 kB
379 B
react-field
Field
20.552 kB
7.092 kB
21.509 kB
7.408 kB
957 B
316 B
react-input
Input
25.747 kB
7.697 kB
26.707 kB
8.113 kB
960 B
416 B
react-progress
ProgressBar
15.961 kB
5.675 kB
16.322 kB
5.822 kB
361 B
147 B
react-radio
RadioGroup
17.988 kB
6.544 kB
18.889 kB
6.929 kB
901 B
385 B
react-select
Select
26.957 kB
8.766 kB
27.915 kB
9.189 kB
958 B
423 B
react-slider
Slider
35.919 kB
11.059 kB
36.845 kB
11.474 kB
926 B
415 B
react-spinbutton
SpinButton
35.648 kB
10.348 kB
36.598 kB
10.752 kB
950 B
404 B
react-switch
Switch
31.413 kB
9.294 kB
32.438 kB
9.706 kB
1.025 kB
412 B
react-table
DataGrid
149.878 kB
40.662 kB
150.829 kB
41.052 kB
951 B
390 B
react-table
Table as DataGrid
138.018 kB
35.282 kB
138.971 kB
35.722 kB
953 B
440 B
react-table
Table (Selection only)
85.849 kB
21.303 kB
86.8 kB
21.742 kB
951 B
439 B
react-table
Table (Sort only)
85.179 kB
21.113 kB
86.13 kB
21.549 kB
951 B
436 B
react-textarea
Textarea
29.07 kB
9.081 kB
30.108 kB
9.478 kB
1.038 kB
397 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
67.994 kB
18.395 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
207.512 kB
57.555 kB
react-components
react-components: FluentProvider & webLightTheme
38.819 kB
12.351 kB
react-portal-compat
PortalCompatProvider
6.446 kB
2.185 kB
react-radio
Radio
35.48 kB
11.126 kB
react-table
Table (Primitives only)
47.119 kB
12.703 kB
🤖 This report was generated against f196c2eb9fe14dbfca668815fc20925cb7618d19

@behowell behowell assigned behowell and unassigned GeoffCoxMSFT Mar 31, 2023
@size-auditor
Copy link

size-auditor bot commented Mar 31, 2023

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: f196c2eb9fe14dbfca668815fc20925cb7618d19 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 31, 2023

🕵 fluentuiv9 No visual regressions between this PR and main

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 31, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3423379:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 31, 2023

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 930 922 5000
Button mount 572 573 5000
Field mount 1635 1643 5000
FluentProvider mount 1176 1185 5000
FluentProviderWithTheme mount 304 324 10
FluentProviderWithTheme virtual-rerender 278 275 10
FluentProviderWithTheme virtual-rerender-with-unmount 298 299 10
InfoButton mount 210 193 5000
MakeStyles mount 1314 1309 50000
Persona mount 2249 2228 5000
SpinButton mount 2013 1982 5000

@behowell behowell marked this pull request as ready for review March 31, 2023 23:20
@spmonahan
Copy link
Contributor

Any ideas why Progress is increasing in size more than other packages?

field_size_progress

@behowell
Copy link
Contributor Author

behowell commented Apr 3, 2023

Any ideas why Progress is increasing in size more than other packages?

I think it's because it had more logic related to merging props, in addition to importing useFieldControlProps_unstable (and ignoring most of what that hook does). I changed it to no longer use useFieldControlProps_unstable, which will hopefully reduce the bundle size.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Field overwrites id of wrapped control

6 participants