Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Preventing blanket selectors from Fabric component from being applied via new preventBlanketFontInheritance prop #25453

Merged
merged 8 commits into from
Nov 3, 2022

Conversation

khmakoto
Copy link
Member

@khmakoto khmakoto commented Oct 31, 2022

Previous Behavior

The Fabric component had blanket selectors for button, input and textarea descendants to apply font-family: inherit styles to them. These are expensive selectors that are actually unneeded since all of the v8 components already have font-family applied to them and it's not the library's responsibility to ensure that non-Fluent components inherit these styles.

New Behavior

The Fabric component now has a new preventBlanketFontInheritance prop. If the prop is set to true, then the Fabric component no longer applies the blanket selectors for button, input and textarea descendants mentioned above, which should improve style recalculation. Anyone who decides to turn the prop on should see no impact on our components since they already define font-family in their styles.

Related Issue(s)

Fixes #24260

@khmakoto khmakoto self-assigned this Oct 31, 2022
@khmakoto khmakoto changed the title fix: Removing blanket selectors from Fabric component and adding them to specific components that use them [DO NOT MERGE YET] fix: Removing blanket selectors from Fabric component and adding them to specific components that use them Oct 31, 2022
@khmakoto khmakoto marked this pull request as ready for review October 31, 2022 23:58
@khmakoto khmakoto requested review from a team and dzearing as code owners October 31, 2022 23:58
@khmakoto khmakoto added the Fluent UI react (v8) Issues about @fluentui/react (v8) label Oct 31, 2022
@size-auditor
Copy link

size-auditor bot commented Nov 1, 2022

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-Dialog 198.63 kB 198.736 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-CommandBar 190.82 kB 190.926 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-DatePicker 175.366 kB 175.472 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-SearchBox 176.934 kB 177.04 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-DocumentCard 204.738 kB 204.844 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-PositioningContainer 68.311 kB 68.417 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Dropdown 220.322 kB 220.428 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Pivot 178.211 kB 178.317 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Pickers 279.208 kB 279.314 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-PersonaCoin 108.057 kB 108.163 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Persona 108.057 kB 108.163 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Facepile 199.668 kB 199.774 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Modal 88.583 kB 88.689 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-MessageBar 178.029 kB 178.135 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Grid 170.063 kB 170.169 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Layer 45.026 kB 45.132 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Keytips 99.234 kB 99.34 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-KeytipLayer 96.497 kB 96.603 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Keytip 75.32 kB 75.426 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-ContextualMenu 145.57 kB 145.676 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-HoverCard 90.489 kB 90.595 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-ShimmeredDetailsList 232.697 kB 232.803 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-ButtonGrid 170.063 kB 170.169 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-ComboBox 236.838 kB 236.944 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-TeachingBubble 193.563 kB 193.669 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-SwatchColorPicker 179.755 kB 179.861 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-TimePicker 225.779 kB 225.885 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Tooltip 80.643 kB 80.749 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-ColorPicker 124.128 kB 124.234 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Breadcrumb 189.789 kB 189.895 kB ExceedsBaseline     106 bytes
office-ui-fabric-react fluentui-react-Callout 77.897 kB 78.002 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-Button 184.23 kB 184.335 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-Nav 177.373 kB 177.478 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-FloatingPicker 229.971 kB 230.076 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-Panel 188.399 kB 188.504 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-SpinButton 180.833 kB 180.938 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-SelectedItemsList 220.379 kB 220.484 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-DetailsList 222.206 kB 222.311 kB ExceedsBaseline     105 bytes
office-ui-fabric-react fluentui-react-Coachmark 86.541 kB 86.643 kB ExceedsBaseline     102 bytes
office-ui-fabric-react fluentui-react-Fabric 39.365 kB 39.393 kB ExceedsBaseline     28 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: 50d5f2ef0d6a06851e78f736055fcc313d61029b (build)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 1, 2022

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 e851b88:

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

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 1, 2022

📊 Bundle size report

🤖 This report was generated against 50d5f2ef0d6a06851e78f736055fcc313d61029b

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 1, 2022

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 1215 1200 5000
Breadcrumb mount 2804 2820 1000
Checkbox mount 2653 2634 5000
CheckboxBase mount 2384 2377 5000
ChoiceGroup mount 4286 4274 5000
ComboBox mount 1183 1181 1000
CommandBar mount 9335 9290 1000
ContextualMenu mount 10157 10220 1000
DefaultButton mount 1365 1381 5000
DetailsRow mount 3396 3368 5000
DetailsRowFast mount 3388 3374 5000
DetailsRowNoStyles mount 3255 3247 5000
Dialog mount 2987 2936 1000
DocumentCardTitle mount 577 593 1000
Dropdown mount 3342 3164 5000
FocusTrapZone mount 1955 1937 5000
FocusZone mount 1986 1973 5000
GroupedList mount 1824 2073 2
GroupedList virtual-rerender 1111 1100 2
GroupedList virtual-rerender-with-unmount 1613 1622 2
GroupedListV2 mount 565 576 2
GroupedListV2 virtual-rerender 549 549 2
GroupedListV2 virtual-rerender-with-unmount 578 564 2
IconButton mount 1788 1819 5000
Label mount 760 760 5000
Layer mount 4142 4266 5000
Link mount 871 854 5000
MenuButton mount 1621 1622 5000
MessageBar mount 2305 2394 5000
Nav mount 3037 3117 1000
OverflowSet mount 1443 1414 5000
Panel mount 2529 2511 1000
Persona mount 1263 1276 1000
Pivot mount 1550 1538 1000
PrimaryButton mount 1494 1513 5000
Rating mount 7028 6981 5000
SearchBox mount 1492 1525 5000
Shimmer mount 2927 2939 5000
Slider mount 2107 2104 5000
SpinButton mount 4263 4310 5000
Spinner mount 826 847 5000
SplitButton mount 2835 2879 5000
Stack mount 883 883 5000
StackWithIntrinsicChildren mount 2347 2329 5000
StackWithTextChildren mount 5082 5029 5000
SwatchColorPicker mount 9590 9585 5000
TagPicker mount 2334 2364 5000
TeachingBubble mount 77133 77561 5000
Text mount 832 844 5000
TextField mount 1561 1577 5000
ThemeProvider mount 1444 1456 5000
ThemeProvider virtual-rerender 1153 1146 5000
ThemeProvider virtual-rerender-with-unmount 2021 2025 5000
Toggle mount 1151 1126 5000
buttonNative mount 546 548 5000

Humberto Makoto Morimoto Burgos and others added 2 commits October 31, 2022 18:06
@khmakoto khmakoto changed the title [DO NOT MERGE YET] fix: Removing blanket selectors from Fabric component and adding them to specific components that use them fix: Removing blanket selectors from Fabric component and adding them to specific components that use them Nov 1, 2022
@khmakoto khmakoto changed the title fix: Removing blanket selectors from Fabric component and adding them to specific components that use them fix: Preventing blanket selectors from Fabric component from being applied via new preventBlanketFontInheritance prop Nov 2, 2022
@khmakoto khmakoto enabled auto-merge (squash) November 2, 2022 23:40
@khmakoto khmakoto merged commit e293389 into microsoft:master Nov 3, 2022
@khmakoto khmakoto deleted the fabricBlanketSelectors branch November 3, 2022 00:13
marcosmoura added a commit to marcosmoura/fluentui that referenced this pull request Nov 3, 2022
* master:
  feat(scripts): improve API violation reporting (microsoft#25356)
  applying package updates
  fix: Preventing blanket selectors from Fabric component from being applied via new preventBlanketFontInheritance prop (microsoft#25453)
  feat(react-infobutton): Add initial implementation (microsoft#25247)
  chore(react-avatar, avatar-context): migrate to new package structure (microsoft#25473)
  chore(react-portal, portal-compat, portal-compat-context): migrate to new package structure (microsoft#25481)
  docs(react-infobutton): Adding component's spec (microsoft#25251)
  fix(screener-build workflow): scope package to build for v9 VR tests to speed up perf (microsoft#25494)
  chore(vr-tests-v9): Convert Button VR tests to CSF (microsoft#25108)
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
…plied via new preventBlanketFontInheritance prop (microsoft#25453)

* fix: Removing blanket selectors from Fabric component and adding them to specific components that use them.

* Updating snapshots.

* Updating snapshots.

* Adding change file.

* Gating behavior behind preventBlanketFontInheritance prop.

* Updating change file.

* Fixing incorrect condition.

* Updating snapshots.

Co-authored-by: Humberto Makoto Morimoto Burgos <makotom@microsoft.com>
Co-authored-by: KHMakoto <humberto_makoto@hotmail.com>
Hotell pushed a commit to Hotell/fluentui that referenced this pull request Feb 9, 2023
…plied via new preventBlanketFontInheritance prop (microsoft#25453)

* fix: Removing blanket selectors from Fabric component and adding them to specific components that use them.

* Updating snapshots.

* Updating snapshots.

* Adding change file.

* Gating behavior behind preventBlanketFontInheritance prop.

* Updating change file.

* Fixing incorrect condition.

* Updating snapshots.

Co-authored-by: Humberto Makoto Morimoto Burgos <makotom@microsoft.com>
Co-authored-by: KHMakoto <humberto_makoto@hotmail.com>
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]: Fabric component has button, input, and textarea selectors that add unneeded overhead to style recalcs
4 participants