Problem/Motivation
#3318817: Improve the categories filter type in context to the rest of the filter component ui will likely be committed with a few shortcomings to keep scope reasonable.
One of those is that when someone is selecting multiple categories, it does a load each time they make a click. It's kind of a bet to hedge to see whether "most people" will click one category, or most want to click multiple. We could potentially solve this and optimize for multiple selections if we added an Apply (and Clear/Reset) button at the bottom of the categories dialog/dropdown.
Proposed resolution
Implement apply and clear buttons at the bottom of the dialog, and wire the behavior so that the filter is only implemented when hitting apply. NOTE that this would only pertain to the categories dialog, NOT the filter set as a whole.
NEXT STEPS:
- start a new branch and re-apply this work manually to the latest 2.0.x (too much has been done)
- write a test that works with the new scrollable div
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | applyandcleardisplayissue.png | 287.39 KB | leslieg |
| #43 | clear_btn.gif | 48.68 MB | libbna |
| #39 | apply-and-clear-sticky.png | 19.78 KB | snehalgaikwad |
| #34 | apply-clear.png | 16.38 KB | libbna |
| #21 | apply and clear out of div.png | 24.85 KB | utkarsh_33 |
Issue fork project_browser-3458840
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lostcarpark commentedOne thing to bear in mind is the buttons could make things more difficult for keyboard users. Some thought would need to be given to make sure they aren't disadvantaged.
Comment #3
rkollerI've added the tag for wcag2.2. sc 3.2.2 https://www.w3.org/WAI/WCAG22/Understanding/on-input.html which basically illustrates why the proposed resolution, having an apply and clear button, is important or probably necessary.
re #2 in what regard would/could the buttons make things more difficult for keyboard users?
Comment #4
chrisfromredfinI agree that the use of apply/clear buttons would enhance the UX. Going to add this to the roadmap.
Comment #5
lostcarpark commented@rkoller At the moment the keyboard user can tab onto the category box, press space to open it, then use up/down arrows to move between categories, and space to select/deselect them. Pressing tab will close the drop-down and move to the next control.
I agree that having the modules change behind the drop-down as we currently do is confusing. We just need to ensure there is a clear an intuative UI for getting from the list of categories to the apply/reset buttons.
Comment #8
utkarsh_33 commentedThis is now down to nightwatch test failures.So I'll try to resolve them else i will post a detailed description of the problem with the tests and maybe solution😅.
Comment #9
utkarsh_33 commentedComment #10
phenaproximaI don't see a ton here to complain about from the code perspective (I haven't manually tested it), but I do have some questions about using styling classes to hook into functional behaviors. That seems like a red flag to me. But maybe I'm missing something?
Comment #11
narendrarFound some issues while testing this MR
Comment #12
utkarsh_33 commentedAll the feedbacks are addressed and tests are also passing.Marking it NR.
Comment #13
chrisfromredfinI have one small UI request. I believe that we need to keep the Apply/Clear buttons visible always as long as the dropdown is shown.
Right now, they are at the very bottom of the scrolling list in the window, and it will not be obvious that someone will need to click that to make the filter work. I would like to see:
[ Dropdown \/ ]
[ Categories here ] - this part is scrollable
[ Apply | Clear ] - Always fixed at the bottom of the popup when someone scrolls
Something like this:

Comment #14
rkoller+1 for making the buttons visible all the time. but there is one potentially tricky problem to consider, the user is navigation the multiselect by the up and down arrow key. how should the transition between the options in the select list and the apply and clear button be accomplished? at the moment if you navigate down to the end of the list the apply button gets into focus but you are unable to reach the clear button by the arrow keys. and if you press the tab key the security advisory coverage select gets into focus. on shift focus you get onto the filter button that was unreachable before. but how to handle things for keyboard users with the position fixed of that apply and clear button i consider tricky.
ps: on the browse page is also get tens of the following redundant errors:
on the latest 2.0.x that doesnt happen
Comment #15
utkarsh_33 commentedI have added CSS changes that fixes the position of the Apply and Clear button.See the SS:-
Comment #16
utkarsh_33 commentedComment #17
chrisfromredfin@utkarsh_33 With many, many apologies, I think I really beefed this. I tried to rebase, which of course meant force-pushing. I then tried to restore, but I think my restore point was prior to these final fixes. If you still have the latest you did locally, can you please force-push it?
Changes remaining that I want:
- max-height of the dropdown should be "50vh" and not a pixel-based value
- Apply and clear buttons should not be space-between, but right next to each other, with clear being 0.5rem away (get rid of justify-content and replace with "gap: 0.5rem;" should do it.
That's it for aesthetic fixes; but then we need to address the a11y of keyboard navigation. I THINK the right/logical thing would be IF it's open, we should be able to tab to the apply/clear buttons. If they're closed, tab should jump to the next filter. (??? ¯\_(ツ)_/¯ )
Comment #18
rkollerin regards of aesthetics two details. first, i am unable to test the current state since it is broken or at least the buttons are not showing anymore at the moment, but in my previous tests i'Ve noticed a regression that is illustrated in #15. we ve agreed on a previous issue that the user should always see only the half of the last visible option if there are more options than vertical available space. that way the user directly knows the list is scrollable. in the screenshot in #15 you see the last visible option fully visible instead. that way it is not directly apparent that the list is visible.
and i wonder if it would make sense to align the background color of that box/bar that contains those two buttons with the dark of the bulk action bar? to visualize that this is a button bar and not part of the multi select list anymore, to make it visualy distinguished from the actual list?
and in regards of the keyboard navigation. would it make sense to move the details about the keyboard navigation into #3458844: Improve keyboard navigation/general a11y for categories dropdown if the rest of this issue is ready?
Comment #19
utkarsh_33 commentedI have adjusted the height to 50vh and also the spacing between the buttons as mentioned in #17. Also i the concern raise by @rkoller in #18 is fixed related to
along with the black background colour for the div containing the 2 buttons (which matches the bulk operation) and now it will be easier for the user to distinguish from the actual list.
Also regarding
I think we could do that as a part of the that issue.
Comment #20
utkarsh_33 commentedAttaching the latest SS for ease of reviewing the changes.
Comment #21
utkarsh_33 commentedThe tests are failing because they are not able to interact with the elements(by scrolling).I can't figure out how does the addition of one more element in the scroll list is causing this issue.
I tried adjusting the z-index for the apply and clear button's div but that also didn't help to fix the problem because as you can see the css of the apply and clear button's div is causing the issue (see the SS).
For better understanding i changed the background colour.
I also tried to move the apply and clear button out of the select list(which is not actually we want) but that seems to pose a greater problem as you can see the SS.
If anyone has any idea of what could be reason for the test fails or what else can i try to fix the problem, it would be helpful if they can document it on the issue or give it a try to fix the problem.
Thanks in advance.
Comment #22
chrisfromredfinhttps://drupal.slack.com/archives/C01UHB4QG12/p1732655176738539
The problem, which I think you know, is that the element is hidden in the scrollable div that's above the buttons, so you can't ->focus() it or ->click() it.
So, I think you would have to somehow figure out how to take that element and scroll it into view. I have tried looking at Mink documentation, and there doesn't seem to be a method to do this. However, I know there's a JavaScript method for it. I think there is a way to execute raw JS during the test, like we do in getElementText() of the ProjectBrowserUiTestTrait.php:
$this->getSession()->evaluateScript(...);
The following diff seems to at least fix the testCategoryFiltering() method, for example.
Comment #23
utkarsh_33 commentedI tried adding the fix
,but it's not working for all the tests.
Comment #24
rkollera brief note about color contrast, the apply button has a too low color contrast. I would go with the same color suggested on the bulk action issue,
--color-blue-400which is already used on the bulk action bar onadmin/content. the general behavior in the context of keyboard navigation i'll retest later today.Comment #25
utkarsh_33 commentedI tried to get the other tests pass but they are not working.
These are the following that i tried:-
mediacategory intestPaging()'scase so that we can click on the media category easily as it is in the viewport.Accessibility.Comment #26
chrisfromredfinNo API considerations, moving to stable. HOWEVER, leaving on the SHOULD HAVEs for -beta1.
Comment #27
chrisfromredfinI wonder if @lostcarpark could turn this part of the testing into a Nightwatch test? I'm not sure if that would actually help or not. Maybe its scrollIntoView works better, or it handles clicking things that aren't visible better...?
Comment #28
phenaproximaThis is extremely out of date, sadly, and needs to be completely refactored to be brought in line with the way the Svelte app currently works. I think we can certainly write an automated test of this.
Comment #29
lostcarpark commentedAgree this is beyond a rebase. Needs a new branch from 2.0, and for the changes to be reworked to match.
Comment #30
chrisfromredfinComment #32
libbna commentedComment #34
libbna commentedI created a new branch, rebased it and applied the changes manually.
Adding the screenshot how the buttons are looking.
I have unassigned the issue so that anyone else can work on tests.
Comment #36
chrisfromredfinThank you, libbna! Good progress. A couple things I'm noticing.
(1) The apply/clear bar should be "sticky" at the bottom of the container that opens. That is, it should always be visible and only the list of checkboxes should be scrollable. That can probably also be a little less tall. Maybe something like a height of whatever 4.5 rows is, with maybe a max-height of like 90vh or something?
(2) the "Clear" button should act as a submit button. So, while it clears the checkboxes, you still have to scroll back down and click Apply, which shouldn't actually be necessary. Hitting clear should wipe out all the category selections and cause a projects refresh.
Comment #39
snehalgaikwad commentedAddressed both points mentioned in #36. Now both buttons will remain sticky, and only the options will be scrollable. Also, the clear button will clear the selected options (no need to click on apply after clear).
Keeping assigned to myself to work on failed pipeline issues.
Comment #41
chrisfromredfinComment #42
chrisfromredfinI've updated this a little bit, but tests are still failing. Some other things I've noticed that need to be fixed:
(1) if you use the "Clear" button it doesn't cause a reload, and it should.
(2) If you check some categories and hit apply, but then use "Clear filters" it doesn't clear the checkboxes from the component.
The experience needs to be aware of all the ways categories may be changed/reset/cleared, etc.
Unassigning in case someone else wants to pick this up.
Comment #43
libbna commentedI have updated the functionality of clear button as suggested in #42.
Comment #44
libbna commentedComment #45
leslieg commentedIf you check some categories and hit apply, then use "Clear filters" it now clears the selected filters, including the selected categories, however it does not clear the checkboxes from the component. The categories still appear with the checkboxes selected. So it's only a display issue. See attached file
Comment #46
leslieg commented