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

YALB-1233: Improved term picker with ChosenJS #334

Merged
merged 43 commits into from
Jul 24, 2023

Conversation

dblanken-yale
Copy link
Contributor

@dblanken-yale dblanken-yale commented Jul 6, 2023

YALB-1233: Improved term picker with ChosenJS

Description of work

  • Add Chosen module
  • Add composer-merge-plugin to handle jjj/chosenjs dependency through composer
  • Change Page, Post, and Event tag entry to use chosen
  • Change Event category to use chosen
  • Change View block's include/exclude fields to use chosen
    • Change listing of include/exclude fields to be sorted by name for easy traversal
  • Changed chosen dropdown colors to provide proper contrast for accessibility
  • Updated help text associated with content types to convey that they cannot add items

Functional testing steps:

Locally

  • Perform a fresh install using npm run setup
  • Ensure that the chosen directory exists afterward in ./web/libraries

Locally or Remotely

  • Create multiple tags and categories beforehand as you cannot add while creating content types
  • Create/edit a post and verify that you can use chosen to select tags
    • Verify while creating that you can view the help by clicking the ? mark and that it is clear and concise
    • Verify that upon save, you can edit and see the tags pre-selected
  • Create/edit a page and verify that you can use chosen to select tags
    • Verify while creating that you can view the help by clicking the ? mark and that it is clear and concise
    • Verify that upon save, you can edit and see the tags pre-selected
  • Create/edit an event and verify that you can use chosen to select tags and categories
    • Verify while creating that you can view the help by clicking the ? mark and that it is clear and concise
    • Verify that upon save, you can edit and see the tags pre-selected
  • On the page created above, add a view block
    • Ensure that you can add include/exclude items and save
  • Validate that the correct items are displayed in the view based on the items you selected
  • Edit the view and ensure that the items you selected before have been pre-selected
  • Think about if there are any places I've missed using Chosen on: so far my focus has been on the content type tags/categories, and the view block filter.

Accessibility testing steps:

  • Do the above functional testing steps on the remote site and verify that the selected drop down items and the unselected drop down items have a proper contrast ratio that meet A/AA standards.
  • Document any other findings that we could possibly create a ticket for and discuss at another time for fixes to either this platform or to chosen upstream.

@dblanken-yale dblanken-yale self-assigned this Jul 6, 2023
@dblanken-yale dblanken-yale force-pushed the YALB-1233-improved-term-picker-with-chosen-js branch 2 times, most recently from c20a972 to b7da273 Compare July 6, 2023 20:07
@github-actions
Copy link

Visit Site

Created multidev environment pr-334 for yalesites-platform.

1 similar comment
@github-actions
Copy link

Visit Site

Created multidev environment pr-334 for yalesites-platform.

@dblanken-yale dblanken-yale force-pushed the YALB-1233-improved-term-picker-with-chosen-js branch from bc358c6 to 5d7e3ea Compare July 10, 2023 21:09
@github-actions
Copy link

Visit Site

Created multidev environment pr-334 for yalesites-platform.

@dblanken-yale dblanken-yale force-pushed the YALB-1233-improved-term-picker-with-chosen-js branch 5 times, most recently from 80ac6a5 to fc058e7 Compare July 12, 2023 13:33
@dblanken-yale dblanken-yale marked this pull request as ready for review July 12, 2023 18:30
Copy link
Contributor

@joetower joetower left a comment

Choose a reason for hiding this comment

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

@dblanken-yale CSS additions looks great to me!

Copy link

@myvaughn myvaughn left a comment

Choose a reason for hiding this comment

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

I will defer to @kara-franco on this, but I approve use of this control for now with the CSS fixes Dave was able to make. This control is better than the Autocomplete Deluxe that was being considered. Longer term, we might consider building our own component for this or wait to see what Drupal core comes up with as a replacement for autocomplete. Since we don't want new terms to be added with this control, the Drupal core option may never be what we want, however.

@dblanken-yale dblanken-yale force-pushed the YALB-1233-improved-term-picker-with-chosen-js branch from 80e5486 to 9d9b32e Compare July 14, 2023 16:42
Copy link

@kara-franco kara-franco left a comment

Choose a reason for hiding this comment

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

The CSS tweaks for the selected menu items looks great! The colors pass the color contrast triangle: https://contrast-triangle.com/?linkColor=%23058260&textColor=%23082538

For future updates/fixes we can:

  • Replace the negative tabindex on the remove/close buttons with tabindex=0
  • Enhance the focus indicator color for the remove/close buttons
  • Add an aria-label="Remove" to the x buttons
  • When a SR user selects the term, feedback needs to be given (Combobo example)

Reference screenshot:
Screenshot 2023-07-14 at 1 31 43 PM

Combobo example: https://dequelabs.github.io/combobo/demo/

Copy link
Contributor

@codechefmarc codechefmarc left a comment

Choose a reason for hiding this comment

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

Tested this on the multidev and all looked good to me! I'm approving, but a few notes:

  1. You can add links into the description box for the tags/categories that can open a new tab to add new terms. Not sure if we want to do that or not. I seem to recall that Franz liked that you can't easily add terms - that it has to be a deliberate action so your solution is probably just fine.
  2. I see you've added a few methods to the ViewsBasicManager that will get the terms and the labels - with vocab. Nice! So, is the code here (https://github.com/yalesites-org/yalesites-project/pull/334/files#diff-f1390886a6a1a2acfda94028c41660896cd1781aba805deb4a13e6e6671a710dL221-L227) needed anymore? (Same goes for terms_exclude field) I didn't test, but I assume you can get rid of the #selection_handler and the #selection_settings and even delete the view I created called "Taxonomy Lookup" (located here: /admin/structure/views/view/taxonomy_lookup)? It all works as coded now, but perhaps test trying to remove that code and delete the view since your code replicates that and we don't want orphaned things in there. Thanks!

@dblanken-yale
Copy link
Contributor Author

@codechefmarc You are absolutely right. I was unsure if those settings were only related to the previous autocomplete or not, so didn't touch them. I removed them and all looks to work well. Thanks for that feedback.

Yes, I was hesitant to provide the link as well. I figure if it's decided it's too verbose, we can update that quickly. :D

This reverts commit afc430c.

Moving this logic into the profile did not work.
This allows a method to retrieve all tags from the taxonomy for use in
our filters.  It appends the vocabulary that the term is a part of so
that users can know where it came from.
Use the existing manager set by the constructor instead of calling
another method to get it each time.
The previous way of getting the IDs was to use the target_id of a term,
but since chosen only cares about key/value pairs, we just get the term
itself.

This change allows the displaying of the view.
When modifying a view, chosen needs the ids that were selected before so
that it can show them as pre-selected.  It no longer uses the target_id
as chosen only cares about key/value pairs.

This fix allows pre-selected saved items to show when editing.
I didn't like the look of this, so I removed it.  I can re-add it if
others wish it to be here, but to me it does not follow our style.
CI seems to be erroring, and looking at the script, it changes into the
profile directoy and attempts to use composer.  Because all of our
allowed plugins are defined in the main repo, I could see why this would
error on us.  I'm attmempting to add it in the hopes it'll be happy,
even if it's redundant.
While the linting and testing were successful by placing the info that
was in the main composer.json into the profile's, the build to pantheon
seems to be failing.  Looking at the error, it's pointing to a file path
that really shouldn't exist.  This made me think I was a bit too heavy
handed on my change, so I'm rolling it back and only keeping the
allow-plugins for composer/installers since that was the original
complaint in the hopes that the build succeeds.
The build complained that this was not in the allow list, so we will be
adding it so that it can build.
The build is now complaining about oomphinc/composer-installers-extender
not being allowed, so we will allow it as well.
This is in the hopes I can define where web/core exists so that the
publish using the profile can properly find bartik.info.yml.  My hope is
that I can use relative url locations using "..".
The accessibility team stated that the color contrast did not pass WCAG
guidelines, so this change allows WCAG A/AA passing while keeping the
Gin colors used.
The linter complained about using ::load, so this was my attempt to try
not using it.
Change the instructions for event category chosen selection so that it
conveys that they cannot create new entries.
Update tag help text for a page to convey that they cannot create new
tags while creating new pages.
Update post help tag text to convey that they cannot create new tags
while creating a post.
Update post tag help text to convey that they cannot create tags while
creating a post.
Update event tag help text to convey that they cannot create new tags
while creating an event.
When looking for a color that worked for Gin, I had access to the
--colorGin<X> variables.  When attempting to use this across the site, I
noticed that they are not always available.  So this change allows what
looks like the alternate way of defining them, which is available at
other locations throughout the site.
It was discussed how to style chosen fields in the ys_views_basic module
since it does not currently include the Gin overrides in the
ys_admin_theme theme.  For now, the decision was to copy the CSS to fix
later.
Now that we are using chosen, we do not need these extra options.
@dblanken-yale dblanken-yale force-pushed the YALB-1233-improved-term-picker-with-chosen-js branch from f710d11 to 147247f Compare July 24, 2023 16:56
@dblanken-yale dblanken-yale merged commit 299ac57 into develop Jul 24, 2023
3 checks passed
@dblanken-yale dblanken-yale deleted the YALB-1233-improved-term-picker-with-chosen-js branch July 24, 2023 18:32
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.

5 participants