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(kbutton): fix unfocusing of kbutton #1984

Merged
merged 1 commit into from
Feb 1, 2024
Merged

Conversation

johncowen
Copy link
Contributor

Summary

Clicking then releasing and moving away from a KButton without a subsequent DOM re-render leaves the KButton in its darker 'focus' state.

This PR changes some selectors to use :focus-visible over just :focus to keep the desired coloring when the browser heuristics have decided that the button should look focused, but doesn't apply them otherwise.

I'm pretty sure this is the correct way to do this going from reading:

For instance, when a button is clicked using a pointing device, the focus is generally not visually indicated, but when a text box needing user input has focus, focus is indicated. While focus styles are always required when users are navigating the page with the keyboard or when focus is managed via scripts, focus styles are not required when the user knows where they are putting focus, such as when they use a pointing device such as a mouse or finger to physically set focus on an element, unless that element continues to need user attention.

https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible#focus_vs_focus-visible

My understanding form the above is that buttons generally should use :focus-visible, whereas something like an input field you should generally use ':focus' i.e. with the input field example, if you are changing the border color on 'focus' you probably want that change to stay when you move the pointer away from the input field.

But if folks have a different approach, happy to close this and go with something else.

Also, please shout if its not clear what the issue is, its a very subtle thing and easy to miss.

P.S guessing there could be other components that have similar issues, but I'm not super familiar with all of them so this only addresses KButton.

PR Checklist

  • Conventional Commits all commits follow the conventional commit standards outlined in the main README.
  • Tests coverage: test coverage was added for new features and bug fixes
  • Docs: includes a technically accurate README

@johncowen johncowen requested a review from a team as a code owner February 1, 2024 13:11
Copy link

netlify bot commented Feb 1, 2024

Deploy Preview for kongponents-sandbox ready!

Name Link
🔨 Latest commit 2172e49
🔍 Latest deploy log https://app.netlify.com/sites/kongponents-sandbox/deploys/65bb988ab5c46300087e040c
😎 Deploy Preview https://deploy-preview-1984--kongponents-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 1, 2024

Deploy Preview for kongponents ready!

Name Link
🔨 Latest commit 2172e49
🔍 Latest deploy log https://app.netlify.com/sites/kongponents/deploys/65bb988aac54640008b02d2f
😎 Deploy Preview https://deploy-preview-1984--kongponents.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@adamdehaven adamdehaven left a comment

Choose a reason for hiding this comment

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

lgtm

@adamdehaven adamdehaven merged commit 38e7945 into alpha Feb 1, 2024
12 of 13 checks passed
@adamdehaven adamdehaven deleted the fix/button-unfocus branch February 1, 2024 17:23
kongponents-bot pushed a commit that referenced this pull request Feb 1, 2024
# [9.0.0-alpha.98](v9.0.0-alpha.97...v9.0.0-alpha.98) (2024-02-01)

### Bug Fixes

* **kbutton:** fix unfocusing of kbutton ([#1984](#1984)) ([38e7945](38e7945))
@kongponents-bot
Copy link
Collaborator

🎉 This PR is included in version 9.0.0-alpha.98 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

3 participants