Problem/Motivation
When Views Filters Summary programmatically triggers a submit on the exposed form, it identifies a submit button via getFilterSubmit(). Currently, candidates are filtered to only enabled and visible elements:
const enabledVisible = candidates.filter((el) => !el.disabled && isVisible(el));
Integrations such as Better Exposed Filters (BEF) sometimes provide a submit-like element that should be programmatically “clicked” even if it is hidden or disabled by configuration "Hide submit button". Under the current logic, such elements are ignored, so the wrong button may be clicked or no auto-submit occurs as intended.
Steps to reproduce
- Add ajax to the view
- Configure better exposed filters with the option "Hide submit button" and "Include reset button (resets all applied exposed filters)"
- Configure views filters summary with the option "Show remove filter link".
- Go to the view and select more than two filters (easy for spotting the issue)
- Click on any of the views filters summary
- The reset button will be clicked rather than the "hidden" submit button
Proposed resolution
Add a short-circuit when [data-bef-auto-submit-click] attribute is present.
Remaining tasks
Create new submodule views_filters_summary_autosubmitAdd a js views-filters-summary-autosubmit-override.js which overrides getFilterSubmit and defaults to the original functionImplement hook_library_info_alter()- Test it
User interface changes
API changes
Data model changes
Issue fork views_filters_summary-3555452
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 #3
tuwebo commentedI will appreciate someone reviewing this MR, pretty sure that I'll probably be missing (or wrongly coding) a lot of things, but at least we have something to work with.
Comment #4
mably commentedHi @tuwedo, thanks for your interesting patch.
Could you move the code into its own submodule?
Something like
views_filters_summary_autosubmitshould be ok.Comment #5
tuwebo commentedWow, thank you so much for the review, that was fast. I didn't have the time to test it, but I've created the module as suggested.
Comment #6
tuwebo commentedComment #7
mably commentedI don't have time to test it right now either.
Let's wait for some RTBC love.
Comment #8
tuwebo commentedI've tested it in a site where I am currently working on, and it looks good. I am not changing the issue's status to RTBC since I think we will need, at least, another validation.
@mably Thank you so much for the review.
Comment #9
mably commentedWe need OOP hooks.