fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Fabric 7.23 is adding ~1.3kB to Checkbox

Open apneer opened this issue 7 years ago • 6 comments

Pr responsible for size increase: https://github.com/OfficeDev/office-ui-fabric-react/pull/9815 This seems to be a big increase for an extra feature.

Priorities and help requested:

Are you willing to submit a PR to fix? No

Requested priority: High

Products/sites affected: OutlookWeb fabric updates

apneer avatar Aug 14 '19 21:08 apneer

Thanks @apneer :)

This I believe was due to indeterminate state support being added.

https://github.com/OfficeDev/office-ui-fabric-react/pull/9815/files

Of the 1.3k added, i am estimating (looking at the size auditor report) about 800 bytes were from the .styles update, and 500 were from the .base update.

I think the feature of supporting indeterminate is important for a number of scenarios. Do you see ways to reduce the impact here and still support indeterminate?

dzearing avatar Aug 15 '19 05:08 dzearing

Paging @maxwellred :)

I could see a few bytes savable in the styling:

              [`:hover .${classNames.checkbox}`]: {
                background: checkboxBackgroundCheckedHovered,
                borderColor: checkboxBorderColorCheckedHovered
              },
              [`:focus .${classNames.checkbox}`]: {
                background: checkboxBackgroundCheckedHovered,
                borderColor: checkboxBorderColorCheckedHovered
              },

I believe these redundant selectors could just be collapsed:

  [`:hover .${classNames.checkbox}, :focus .${classNames.checkbox}`]: {
    background: checkboxBackgroundCheckedHovered,
    borderColor: checkboxBorderColorCheckedHovered
},

I see a number of redundant classes.

dzearing avatar Aug 15 '19 05:08 dzearing

@dzearing wouldn't collapsing those selectors make it that much harder/nigh impossible to say, just overwrite just the hover style border color? You will have to resort to specificity/!important

cliffkoh avatar Aug 15 '19 09:08 cliffkoh

I have been talking to @apneer about this on the side to determine possible resolutions. This is a core feature since native input supports indeterminate, so I was going to look at methods for reducing the implementation size.

In addition to the things you pointed out, there seems to be both redundant logic and styling in Checkbox.styles.ts. indeterminate is checked both inside of indeterminateDotStyles and before it's applied in the only place I see it used. This seems to imply that the logic is redundant and that some of the styling is dead code and would never be applied correctly. Hoping @maxwellred can add some input too.

JasonGore avatar Aug 15 '19 15:08 JasonGore

@cliffkoh Having a comma delimited selector does not increase specificity; but I don't think that's what you meant. I think you meant overriding the exact selector is now harder.

Honestly I don't expect a developer to be overriding these, and if they are, just use !important, because assuming that you can override a selector with 2 levels of specificity is just too fragile to design around (especially when you add a dynamically generated classname.)

This is what prompted the tokens discussion.

dzearing avatar Aug 16 '19 05:08 dzearing

:tada:This issue was addressed in #10170, which has now been successfully released as [email protected].:tada:

Handy links:

msft-github-bot avatar Aug 26 '19 12:08 msft-github-bot