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

Cleanup tag display for long lists of tags #3808

Merged
merged 11 commits into from Mar 19, 2024
Merged

Cleanup tag display for long lists of tags #3808

merged 11 commits into from Mar 19, 2024

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Feb 19, 2024

Fixes

Fixes #2589 by @zackkrida

Description

This PR hides the tags beyond the third row and shows a "Show more tags" button if there are hidden tags.

I first tried simply hiding the tags setting the max height and using overflow-hidden. However, this way, you can navigate to the hidden tags using Tab. Even though those tags are not visible, they are focusable and are read by the screenreader.

That's why I added a function that detects the index of the tag that is the first on the 4th line of tags, and set the visibleTags value to the tags up to the "first on the 4th line". When the user clicks show more, the visibleTags is set to all of the tags, and when they click on hide tags, the visibleTags array only contains the first 3 lines.

For counting the rows of tags, I used offsetLeft, but had to make comparison operator (< or >) conditional to make it work with RTL (some of the first VR tests here for RTL are failures because I only used one comparison)

The expander button has a aria-expanded set to true or false based on whether the tags are all shown, or hidden.

Testing Instructions

Enable the additional_search_views on the /preferences page (note that this is only implemented for when this flag is on)
Go to an image result with many tags, such as [http://localhost:8443/image/7e138814-e774-45fb-91ee-7b728c174616?q=Titmouse](http://localhost:8443/image/7e138814-e774-45fb-91ee-7b728c174616?q=Titmouse).
Check that only the 3 rows of tags are displayed, with a "Show more tags" button. Try clicking on the button. The first opened tag should be focused, and the "See less" button should be displayed.
Check that this works for pages with other locales, and that the tags for media with fewer tags are displayed as before.

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 (if 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.

@openverse-bot openverse-bot added 🟨 priority: medium Not blocking but should be addressed soon ✨ goal: improvement Improvement to an existing user-facing feature 🖼️ aspect: design Concerns related to design 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Feb 19, 2024
@github-actions github-actions bot added the 🧱 stack: frontend Related to the Nuxt frontend label Feb 19, 2024
@obulat obulat removed the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label Feb 20, 2024
@obulat obulat force-pushed the add/tags-cleanup branch 2 times, most recently from adbcdc6 to dd444dc Compare March 7, 2024 05:50
@obulat obulat self-assigned this Mar 7, 2024
@obulat obulat marked this pull request as ready for review March 7, 2024 08:23
@obulat obulat requested a review from a team as a code owner March 7, 2024 08:23
@obulat obulat requested review from zackkrida and dhruvkb March 7, 2024 08:23
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

This works so well 🎉 I made one suggestion for code quality, but functionality-wise this is awesome.

@obulat obulat marked this pull request as draft March 11, 2024 14:59
@obulat obulat force-pushed the add/tags-cleanup branch 2 times, most recently from 651462d to 2d053e4 Compare March 12, 2024 03:28
@obulat obulat marked this pull request as ready for review March 12, 2024 03:48
@zackkrida zackkrida self-requested a review March 15, 2024 17:16
@zackkrida zackkrida marked this pull request as draft March 15, 2024 17:16
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

@obulat I've drafted this so we can make the changes discussed in Slack:

  • Add a TOGGLE_TAG_EXPANSION (or similar name) analytics event
  • Finalize the language

@obulat obulat force-pushed the add/tags-cleanup branch 2 times, most recently from c0db3fe to 02c57f7 Compare March 17, 2024 04:08
@obulat obulat marked this pull request as ready for review March 17, 2024 04:21
@zackkrida zackkrida self-requested a review March 17, 2024 14:58
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

LGTM! I have a few suggestions but I will not block this PR.

frontend/src/locales/scripts/en.json5 Show resolved Hide resolved
frontend/src/utils/focus-management.ts Outdated Show resolved Hide resolved
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
Signed-off-by: Olga Bulat <obulat@gmail.com>
@obulat obulat merged commit 775c0df into main Mar 19, 2024
39 checks passed
@obulat obulat deleted the add/tags-cleanup branch March 19, 2024 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖼️ aspect: design Concerns related to design ✨ goal: improvement Improvement to an existing user-facing feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Cleanup tag display with long lists of tags
4 participants