Skip to content

fix(react-avatar): Fixing focus indicator in dark theme for pie layout#23860

Merged
sopranopillow merged 5 commits intomicrosoft:masterfrom
sopranopillow:avatargroup-focus
Jul 12, 2022
Merged

fix(react-avatar): Fixing focus indicator in dark theme for pie layout#23860
sopranopillow merged 5 commits intomicrosoft:masterfrom
sopranopillow:avatargroup-focus

Conversation

@sopranopillow
Copy link
Contributor

Current Behavior

image

Focus indicator for the pie layout was showing up as black, this turned out to be because the actual focus indicator wasn't showing up.

New Behavior

image

The focus indicator for the pie layout is now using border instead of outline and is now applied to the button.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 11, 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 ccf3f15:

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

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 11, 2022

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-avatar
AvatarGroup
136.845 kB
40.741 kB
137.325 kB
40.831 kB
480 B
90 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-alert
Alert
80.938 kB
20.342 kB
react-avatar
Avatar
47.36 kB
13.625 kB
react-avatar
AvatarGroupItem
67.075 kB
18.96 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
189.182 kB
52.141 kB
react-components
react-components: FluentProvider & webLightTheme
31.883 kB
10.516 kB
🤖 This report was generated against 185ff7328615be1d8c0afd33cc8da767ea8dd891

@size-auditor
Copy link

size-auditor bot commented Jul 11, 2022

Asset size changes

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

Baseline commit: 185ff7328615be1d8c0afd33cc8da767ea8dd891 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 11, 2022

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1287 1281 5000
Button mount 872 876 5000
FluentProvider mount 1632 1605 5000
FluentProviderWithTheme mount 569 563 10
FluentProviderWithTheme virtual-rerender 528 536 10
FluentProviderWithTheme virtual-rerender-with-unmount 577 570 10
MakeStyles mount 2024 1987 50000
SpinButton mount 2440 2435 5000


// This custom focus indicator is required for the pie layout due to the clip-path applied to the root
pieFocusIndicator: createCustomFocusIndicatorStyle({
...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorStrokeFocus2),
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the border thickness on focus could theoretically cause a layout shift, although it might be ok in this case (?)

Alternatively, could you use an ::after element to draw the border? Or even just use the default createFocusOutlineStyle, which uses ::after?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, I'll try it out and see which one works best. Thanks!

Copy link
Contributor Author

@sopranopillow sopranopillow Jul 11, 2022

Choose a reason for hiding this comment

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

@behowell After trying it out, I will have to keep it as id. The reasoning is that I feel this way, it makes it simpler rather than adding the ::after pseudo-element, which shouldn't have any problems due to the button being completely transparent. This styling is only applied to the pie layout therefore the others work as expected. Another reason is that the border is "inside" the circle since by using clip-path the outline won't show, this is done with inline-flex because it adds box-sizing: border-box by default (also, layout shouldn't shift because of the border being applied this way). Overall, I think this is the cleanest way, but I don't mind adding the ::after and size it like the root if preferred.

Copy link
Contributor

Choose a reason for hiding this comment

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

An right, I had forgotten that this is an empty button, separate from the element that contains the pie slices, right? In that case, changing its border thickness won't affect anything, and this should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, it's a plain button with transparent styling.


// This custom focus indicator is required for the pie layout due to the clip-path applied to the root
pieFocusIndicator: createCustomFocusIndicatorStyle({
...shorthands.border(tokens.strokeWidthThick, 'solid', tokens.colorStrokeFocus2),
Copy link
Contributor

Choose a reason for hiding this comment

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

An right, I had forgotten that this is an empty button, separate from the element that contains the pie slices, right? In that case, changing its border thickness won't affect anything, and this should be fine.

@sopranopillow sopranopillow merged commit e1b9893 into microsoft:master Jul 12, 2022
@sopranopillow sopranopillow deleted the avatargroup-focus branch July 12, 2022 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants