Skip to content

Conversation

@lubber-de
Copy link
Member

@lubber-de lubber-de commented May 24, 2023

Description

This PR allows to declare a specific focus-visible outline for some components where the default outline is set to none.
The default will be kept to none because FUI mostly shows focus by providing a different color (e.g. buttons) or would not visually fit.

To reduce CSS selectors only a value != none will be rendered, so by default the CSS output wont change

Now the user can decide to change @focusVisibleOutline globally in a custom site.variables or individually inside a custom themes {component.variables}

Closes

#2799

@lubber-de lubber-de added type/feat Any feature requests or improvements lang/css Anything involving CSS state/awaiting-reviews Pull requests which are waiting for reviews labels May 24, 2023
@lubber-de lubber-de added this to the 2.9.3 milestone May 24, 2023
@mvorisek
Copy link
Contributor

See https://stackoverflow.com/questions/31402576/enable-focus-only-on-keyboard-use-or-tab-press for analysis how big players style it.

In #2799 I have described an issue for tab focus for button (and dropdown). As the PR is coded now, it will imply outline for :focus, ie. bold outline for buttons clicked by a mouse. This is not wanted.

Is there any way how to simply not add outline: none when :focus-visible is active? At least for browsers that support this pseudo class - https://caniuse.com/css-focus-visible.

@lubber-de lubber-de modified the milestones: 2.9.3, 2.9.x May 24, 2023
@lubber-de
Copy link
Member Author

Is there any way how to simply not add outline: none when :focus-visible is active? At least for browsers that support this pseudo class - caniuse.com/css-focus-visible.

Sure

.ui.button:focus-visible {
  outline: revert;
}

https://jsfiddle.net/lubber/y0ba824e/10/

@mvorisek
Copy link
Contributor

Yes, please add this revert style for buttons and other important components.

@lubber-de
Copy link
Member Author

lubber-de commented May 24, 2023

Yes, please add this revert style for buttons and other important components.

No, at least not now, because that won't fit the FUI default theme and every browser displays that differently. If you want this consistent people should be able to define the outline as desired via changing the less variables in this PR.

And there are combinations like labeled input where this would need additional styling to look good.

If you don't care about all this, then i suggest to add this as custom css in your app. Putting this hardcoded into FUI ,i can already hear several people scream about the visual change in the next version

@mvorisek
Copy link
Contributor

I consider this a bug. .ui.button:focus-visible selector will not focus visually on a button click nor if a button has no tabindex set. So there should be no visual change on anything except when a button is navigated via tab which deserves a proper styling. I belive the current Fomantic-UI simply does not account for tab focus styling.

One proof - a:focus-visible is styled currently natively as well. Just try it. Another proof - for ex. Google does not style it as well ;-).

So I propose:
a) revert the outline for button with .ui.button:focus-visible selector
b) fix tab visual focus of dropdown to match regular (styled by Fomantic-UI) input style (currently dropdown glow is based on open/close, not on (regular) focus)
c) review other outline: none/0 cases case by case

@lubber-de lubber-de added state/on-hold Issues and pull requests which are on hold for any reason and removed state/awaiting-reviews Pull requests which are waiting for reviews labels May 24, 2023
@lubber-de lubber-de marked this pull request as draft May 24, 2023 16:42
@mvorisek
Copy link
Contributor

mvorisek commented May 25, 2023

Here is a default FF style obtained from about:config FF:
image

preview:
image

so outline-offset (and maybe other CSS properties) needs to be reverted as well

Current Fomantic-UI button/dropdown/checkbox UX can be tested on https://dev.atk4.org/demos/form-control/input2.php.

@lubber-de lubber-de modified the milestones: 2.9.x, 2.10.x Feb 19, 2025
@lubber-de lubber-de changed the title feat(chore): optional outline on focus feat(chore): optional outline on focus-visible May 30, 2025
@lubber-de
Copy link
Member Author

lubber-de commented May 30, 2025

Update

I changed the PR to support custom outline and outline-offset styling for :focus-visible now.
Simply setting @focusVisibleOutline: revert; will apply the browsers default style on focus-visible everywhere.

Next steps/ todo:

  • crossbrowser check the default styling on focus-visible (when reverting as mentioned above) for all the components and their variants
  • adjust/apply a proper FUI like styling and change the defaults for @focusVisibleOutline and @focusVisibleOutlineOffset accordingly in site.variables
  • check combined variants (like labeled input) and add additional variables and selector for such stylings if needed
  • create a custom theme to be able to keep using none for people still wanting the old behavior

ko2in
ko2in previously approved these changes Jun 9, 2025
Copy link
Member

@ko2in ko2in left a comment

Choose a reason for hiding this comment

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

LGTM.

# Conflicts:
#	src/definitions/modules/dropdown.less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/css Anything involving CSS state/on-hold Issues and pull requests which are on hold for any reason type/feat Any feature requests or improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants