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 link focus rings #4958

Closed
wants to merge 4 commits into from
Closed

Fix link focus rings #4958

wants to merge 4 commits into from

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Sep 19, 2024

Fixes

Related to #4911 by @zackkrida

Description

This PR fixes most of the focus ring problems for VLink elements.

Most of VLink elements use the default outline that the browser automatically activates on focus. This PR correctly sets the color of the outline. In Chrome, the default auto outline style generates two-tiered outline (dark/light), to make sure it works in both dark and light themes). However, since we set the color of the outline with an appropriate contrast, we can use a single-color outline. To do that, we set the default outline style for focus-visible to solid, which creates a ring of single color.

To make the outline rounded, if a VLink does not set a rounded- class, then we add rounded-sm (border-radius: 2px) to it.

Testing Instructions

  1. Run the app using ov just frontend/run dev
  2. Go to http://localhost:8443/ and navigate around using Tab. The links in the header/footer, Openverse link and the WordPress link, as well as other links throughout the site should have a rounded outline of correct color: pink in light theme, and yellow in dark theme.
  3. Narrow your screen to mobile width, and open the pages modal by clicking on the hamburger in the top right corner (on LTR). The focus rings here should always be yellow, even if the app's color theme is light.

Use the Storybook to test the links, e.g., Internal header: https://docs.openverse.org/_preview/4958/storybook/?path=/story/components-vheader-vheaderinternal--default&globals=viewport:xs

Note that in the light mode, the Openverse link and the close button in the modal still has a pink focus outline, it will be fixed in a later PR.

Check different browsers.

This PR also contains a fix to an e2e test that failed twice in the CI. The fix was to check that the sensitive switch was indeed changed before checking for the cookies.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@obulat obulat requested a review from a team as a code owner September 19, 2024 11:04
@openverse-bot openverse-bot added 🧱 stack: documentation Related to Sphinx documentation 🧱 stack: frontend Related to the Nuxt frontend 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Sep 19, 2024
@obulat obulat mentioned this pull request Sep 19, 2024
8 tasks
@obulat obulat added 🟧 priority: high Stalls work on the project or its dependents 🕹 aspect: interface Concerns end-users' experience with the software 🛠 goal: fix Bug fix and removed 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Sep 19, 2024
@obulat obulat force-pushed the fix/link-focus-rings branch 2 times, most recently from 8940e6b to 8a1e648 Compare September 19, 2024 14:28
Copy link

Full-stack documentation: https://docs.openverse.org/_preview/4958

Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.

You can check the GitHub pages deployment action list to see the current status of the deployments.

@obulat obulat force-pushed the fix/link-focus-rings branch 2 times, most recently from e9634bb to 4981994 Compare September 19, 2024 15:57
@obulat obulat changed the title Fix link focus rings and focus-slim-offset styles Fix link focus rings Sep 19, 2024
@obulat obulat force-pushed the fix/link-focus-rings branch 2 times, most recently from 2a465ec to ea74eb4 Compare September 20, 2024 06:47
@obulat obulat self-assigned this Sep 20, 2024
@obulat obulat force-pushed the fix/link-focus-rings branch 2 times, most recently from 9ee8226 to cc875c5 Compare September 24, 2024 03:29
Copy link
Collaborator

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

@obulat @zackkrida are there plans to refactor the WP logo component to use the CSS-only methods of colour scheme detection? I suppose it retains the JS approach in order to support the mobile nav, which is always in dark mode... but could the mobile nav add the dark mode classname to its root element, and then follow the same approach for colours as the rest of the application? It will be confusing long term to have the JS-based pattern still present in the app, for anyone trying to understand how to correctly style components.

frontend/tailwind.config.ts Outdated Show resolved Hide resolved
@obulat
Copy link
Contributor Author

obulat commented Sep 25, 2024

@obulat @zackkrida are there plans to refactor the WP logo component to use the CSS-only methods of colour scheme detection? I suppose it retains the JS approach in order to support the mobile nav, which is always in dark mode... but could the mobile nav add the dark mode classname to its root element, and then follow the same approach for colours as the rest of the application? It will be confusing long term to have the JS-based pattern still present in the app, for anyone trying to understand how to correctly style components.

The mobile pages modal is always black, in dark and in light theme. We use a CSS variable to set the background color of the current page, and in this modal, we set it to black (even though in the main app it can be yellow on the homepage for light, and dark gray for dark theme). We could set a similar "contrast text color" variable when we set the page background color variable for the colors of the WordPress link and Openverse logo. Would that be a better approach?

@obulat obulat force-pushed the fix/link-focus-rings branch 3 times, most recently from a63826b to bd3edf8 Compare September 25, 2024 15:50
@obulat obulat marked this pull request as draft September 25, 2024 16:34
@zackkrida
Copy link
Member

zackkrida commented Sep 25, 2024

@sarayourfriend that's a great idea. @obulat is that suggestion makes sense to you as well could you create an issue for it?

Copy link

github-actions bot commented Sep 26, 2024

Latest k6 run output1

$     ✓ status was 200

     checks.........................: 100.00% ✓ 8000      ✗ 0   
     data_received..................: 1.8 GB  7.8 MB/s
     data_sent......................: 1.0 MB  4.5 kB/s
     http_req_blocked...............: avg=20.44µs  min=1.86µs   med=4.32µs   max=10.07ms p(90)=5.71µs   p(95)=6.2µs   
     http_req_connecting............: avg=15.67µs  min=0s       med=0s       max=10.01ms p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=603.74ms min=47.43ms  med=534.07ms max=2.56s   p(90)=1.12s    p(95)=1.24s   
       { expected_response:true }...: avg=603.74ms min=47.43ms  med=534.07ms max=2.56s   p(90)=1.12s    p(95)=1.24s   
   ✓ http_req_failed................: 0.00%   ✓ 0         ✗ 8000
     http_req_receiving.............: avg=156.67µs min=42.35µs  med=123.09µs max=31.96ms p(90)=189.77µs p(95)=228.24µs
     http_req_sending...............: avg=21.54µs  min=6.9µs    med=20.78µs  max=1.75ms  p(90)=26.77µs  p(95)=28.81µs 
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s      p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=603.56ms min=47.3ms   med=533.93ms max=2.56s   p(90)=1.12s    p(95)=1.24s   
     http_reqs......................: 8000    34.350314/s
     iteration_duration.............: avg=4.03s    min=976.18ms med=3.44s    max=12.76s  p(90)=8.69s    p(95)=9.23s   
     iterations.....................: 1200    5.152547/s
     vus............................: 3       min=3       max=30
     vus_max........................: 30      min=30      max=30

Footnotes

  1. This comment will automatically update with new output each time k6 runs for this PR

@obulat obulat marked this pull request as ready for review September 26, 2024 17:28
@obulat
Copy link
Contributor Author

obulat commented Sep 26, 2024

@sarayourfriend that's a great idea. @obulat is that suggestion makes sense to you as well could you create an issue for it?

Issue opened: #4998

@obulat obulat force-pushed the fix/link-focus-rings branch 2 times, most recently from 6bbb734 to b2ec51f Compare October 8, 2024 11:50
@openverse-bot
Copy link
Collaborator

Based on the high urgency of this PR, the following reviewers are being gently reminded to review this PR:

@zackkrida
@dhruvkb
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 10 day(s) ago. PRs labelled with high urgency are expected to be reviewed within 2 weekday(s)2.

@obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

@obulat obulat force-pushed the fix/link-focus-rings branch 2 times, most recently from 5a401e9 to b9a0b59 Compare October 11, 2024 14:42
@obulat obulat removed the request for review from zackkrida October 11, 2024 17:01
@obulat obulat marked this pull request as draft October 11, 2024 18:38
@obulat obulat force-pushed the fix/link-focus-rings branch 2 times, most recently from 6f223aa to 815669b Compare October 17, 2024 09:47
@obulat obulat mentioned this pull request Oct 17, 2024
8 tasks
@obulat obulat marked this pull request as ready for review October 17, 2024 10:47
@obulat
Copy link
Contributor Author

obulat commented Oct 18, 2024

These changes were merged with #4983.

@obulat obulat closed this Oct 18, 2024
@obulat obulat deleted the fix/link-focus-rings branch October 18, 2024 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕹 aspect: interface Concerns end-users' experience with the software 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: documentation Related to Sphinx documentation 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants