-
Notifications
You must be signed in to change notification settings - Fork 3
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 focus visibility in theme settings #245
Conversation
…he color to blue. Compiled using compile_styles.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sreidthomas would you test and provide a video of the test?
It looks this change doesn't fix the focus visibility of the dropdown button on the responsive offcanvas menu:
2024-07-22.10-29-24.mp4
We'll need to make this work for the dropdown button and test it before merge.
For fixing the the offcanvas dropdown button, I'd recommend looking at the bootstrap ruleset for .btn:focus-visible
, figuring out why our blue
focus configuration is not applying to that rule, then figuring out the way to fix that. Let me know if you want some additional ideas of what to check.
TO-DO AS OF JULY 23, 2024:
|
Any other help you can give for this PR? I am still not able to get the var(--bs-btn-focus-box-shadow) to show as defined @maxatdetroit |
NOTES ABOUT btn-focus-box-shadow
|
To set the box shadow for buttons on the :focus-visible state in Bootstrap 5.3, you should set the In src/scss/_host.scss, add the following under both the light and dark mode --bs-btn-focus-box-shadow: 0 0 0 0.25rem blue; Note: This is how you would accomplish what you suggested:
|
So I'm testing this solution, and when that variable gets added, isn't the dropdown shadow supposed to be blue @maxatdetroit? Also, how did you know it should be the host.scss file? |
Yes, it should. If it isn't turning blue, make sure you've regenerated the CSS from the SCSS using your script:
This is the bootstrap documentation that suggests modifying the I learned this while reading all the code and reading those links I just shared a while back while getting up to speed on custom elements, bootstrap, and shadow DOM styling. |
I did run the ./scripts/compile_styles.sh command but its still not blue. The links inside are black @maxatdetroit: |
You'll have to take a look in the inspector and make sure the variable is set in the browser and that its impacting the stylesheets the way you'd expect (e.g. make sure that |
Even after adding it to that file, it still says undefined. Is there anything else I should check @maxatdetroit? |
When we update something in the source code, then compile it, and serve the minified/aggregated version in the browser, we know that the breakdown is somewhere in that sequence of events:
I would check out the remaining suggestions above with a ❓ next to them. Let me know if you want some more details about how to go about checking those. My notes are sort of brief above. |
How do I download the CSS file from the browser @maxatdetroit? |
I followed steps from this: https://webdeveloper.com/bounties/how-to-download-css-file-from-a-website/ But I don't see the relevant CSS files |
Here's a way to find the relevant stylesheets using a combination of the inspector element picker and the stylesheet tab: 2024-07-29.12-51-29.mp4Our stylesheets are a little different than most websites because they're all inline stylesheets in the design system (as opposed to external stylesheets with helpful names). |
Is there an easy way to find where else the variable is being set @maxatdetroit? I only switched browsers. I'm using FireFox and now the dropdown links are blue. In Chrome, they were black. I'm using the same code but getting different FIREFOX:CHROME: |
Regarding Different Styles in Different BrowsersThat is expected. Default browser stylesheets, also known as user agent stylesheets, are a set of CSS rules that browsers apply to HTML elements by default. These stylesheets provide basic styling and layout for web pages even when no custom CSS is specified by the web developer. The purpose of default stylesheets is to ensure that HTML documents have a consistent, readable appearance out of the box. They define things like:
However, these default styles can vary between browsers, which is one reason why web developers often use CSS reset or normalization techniques to create a more consistent cross-browser starting point. Now, regarding the
|
Regarding How to Find Where a CSS Variable is SetTry using the 'Computed' tab of the style inspector in the dev tools. You can use the filter to filter down to a specific variable name, then expand the notes for that variable and it will tell you all the cascading styles and how they're overriding each other. Here's a video: 2024-07-29.16-25-47.mp4 |
Since Chrome and Firefox are behaving differently and that's normal, which browser should I focus on as far as this PR goes @maxatdetroit? |
@sreidthomas , we should make sure the fix works on both browsers. Ideally, they have the same style behavior too (e.g. both are blue) but as long as there's a focus indicator with sufficient contrast on each browser, then it's not strictly necessary that they're the same exact styles. |
NEW NOTES AND FINDINGS AS OF JULY 30, 2024:
|
Okay, so I think I found the issue. The .btn class has the btn-focus-box-shadow property set. When I remove it in Developer Tools, the blue highlight around dropdown shows @maxatdetroit, I'm just not sure what file to make the change in. I tried adding this line to _host.scss but it did not work:
|
@sreidthomas very nice investigative work! Based on the video, it looks to me like the
This can also mean they've never been set in the first place. Have you tried setting the |
I set it to blue @maxatdetroit? |
I think it expects an RGB format. |
I set that variable in the file but it didn't work. It's only when I remove the whole thing like in the video that the blue highlight works @maxatdetroit |
Would you try using the debugging tools/workflow you've been using to figure out why? If you get stuck on something, let me know and I can look as well. |
WHERE I BECAME BLOCKED ON THIS ISSUE:Found how the property --bs-btn-focus-shadow-rgb is being set twice but not sure where/how to fix the issue. Currently right now, inside the .btn class if you disable the property, the blue shadow box shows but when it is enabled, the same property is being used but with lesser values so the blue shadow box is there but not as visible. Video was posted on teams demonstrating this |
After the most recent commits, this is now working for all elements, including buttons. @sreidthomas for future reference, the problem with the buttons was that How did I find that? With the help of the 'computed styles' pane in dev tools, I noticed all the styles were being set in the main bootstrap style sheet. So then I read through the compiled bootstrap styles in How did I fix it? I moved the variable definition into |
Latest test: Screen.Recording.2024-07-31.at.3.01.23.PM.mov |
The Problem
When using tab to focus light elements on a dark background (as someone might due using a keyboard to navigate a site), the focus visibility of elements is non-apparent.
The Solution
Override the
$focus-ring-color
SCSS variable and set it toblue
instead of$primary
insrc/scss/_bootstrap-variables.scss
.Then regenerate the theme CSS using
./scripts/compile_styles.sh
.Additional Information
LINK TO ISSUE: https://github.com/CityOfDetroit/COD-Design-System/issues/244