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

[Bug]: Focus border generated by createFocusOutlineStyle can be cut/invisible when parent container is overflow: hidden #31745

Open
2 tasks done
wfwf1997 opened this issue Jun 18, 2024 · 6 comments

Comments

@wfwf1997
Copy link
Contributor

Library

React Components / v9 (@fluentui/react-components)

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (20) x64 Intel(R) Core(TM) i9-10900X CPU @ 3.70GHz
    Memory: 27.87 GB / 31.21 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh

Are you reporting Accessibility issue?

yes

Reproduction

https://codesandbox.io/p/sandbox/vigorous-firefly-mnrppk

Bug Description

Actual Behavior

The focus border is partially visible, or not visible in some cases.
image

Expected Behavior

The focus border should always be fully visible.
image

Logs

No response

Requested priority

High

Products/sites affected

No response

Are you willing to submit a PR to fix?

no

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@mainframev
Copy link
Contributor

mainframev commented Jun 21, 2024

Hi @wfwf1997 👋🏻

I guess with current focus style implementation, where it's set as absolutely positioned border with some offset, it will be always cut by parent padding and overflow:hidden. It have to be solved where is the overflow property set. You can have a negative margin workaround on a parent container. In the case you provided, you can apply something like that to a parent div, where is the overflow property set:

const useStyles = makeStyles({
  hidden: {
   ...shorthands.overflow("hidden"),
   ...shorthands.margin("0", "-8px"),
   ...shorthands.padding("0", "8px"),
  },
  inlineFlex: {
    display: "inline-flex",
  },
});

You can also try to use overflow: clip, but that works only for single axe.
Plus, I think would be a nice option to have a prop to control the offset, so if needed, user can turn off offset for focus ring.

ScreenRecording2024-06-21at14 59 46-ezgif com-video-to-gif-converter

@wfwf1997
Copy link
Contributor Author

Thanks @mainframev for your solution. I suppose this approach do work. But it may hard to find out and fix every occurence of such clipping in a large codebase. I wonder if we can change the implementation or design to make these borders not that easy to get clipped.

no assignees

Gentle ping that this issue needs attention.

@ling1726
Copy link
Member

ling1726 commented Oct 22, 2024

It seems that native outline styles by default also have this problem https://stackblitz.com/edit/vitejs-vite-nayfuf?file=src%2Fstyle.css,src%2Fmain.ts&terminal=dev

Playing around with it I think what the user agent does is apply a default outline-offset: -2px to native focus outlines which are styled as outline-style: auto

Perhaps we should consider a default outline offset for Fluent focus outlines like the user agent does

@ling1726 ling1726 added the Status: Blocked Resolution blocked by another issue label Oct 22, 2024
@ling1726
Copy link
Member

I have a draft PR here #33097 that sets a -2px focus outline, this will resolve issues for the switch and checkbox examples provided in the repro since they do not have offsets set by default

However this will do nothing for the slider unfortunately since the offset is explicitly set in code

focusIndicatorHorizontal: createFocusOutlineStyle({
selector: 'focus-within',
style: { outlineOffset: { top: '-2px', bottom: '-2px', left: '8px', right: '8px' } },
}),
focusIndicatorVertical: createFocusOutlineStyle({
selector: 'focus-within',
style: { outlineOffset: { top: '6px', bottom: '6px', left: '4px', right: '4px' } },

@ling1726
Copy link
Member

/azp run

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

No branches or pull requests

4 participants