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

  1. Add ajax to the view
  2. Configure better exposed filters with the option "Hide submit button" and "Include reset button (resets all applied exposed filters)"
  3. Configure views filters summary with the option "Show remove filter link".
  4. Go to the view and select more than two filters (easy for spotting the issue)
  5. Click on any of the views filters summary
  6. 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

  1. Create new submodule views_filters_summary_autosubmit
  2. Add a js views-filters-summary-autosubmit-override.js which overrides getFilterSubmit and defaults to the original function
  3. Implement hook_library_info_alter()
  4. Test it

User interface changes

API changes

Data model changes

Command icon 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

tuwebo created an issue. See original summary.

tuwebo’s picture

Assigned: tuwebo » Unassigned
Status: Active » Needs review

I 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.

mably’s picture

Status: Needs review » Needs work

Hi @tuwedo, thanks for your interesting patch.

Could you move the code into its own submodule?

Something like views_filters_summary_autosubmit should be ok.

tuwebo’s picture

Status: Needs work » Needs review

Wow, 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.

tuwebo’s picture

Issue summary: View changes
mably’s picture

I don't have time to test it right now either.

Let's wait for some RTBC love.

tuwebo’s picture

I'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.

mably’s picture

Status: Needs review » Needs work

We need OOP hooks.