Problem/Motivation
Since Drupal core added removeExposedFiltersQueryParameters() to ajax_view.js (fix for #3121172), entity browser views with exposed filters throw a JavaScript error:
TypeError: parameter 1 is not of type 'HTMLFormElement' at Drupal.views.ajaxView.removeExposedFiltersQueryParameters
Core's removeExposedFiltersQueryParameters() calls new FormData($exposedForm.get(0)), which requires an HTMLFormElement. In entity browser, the view's exposed form is rendered as a <div> (not <form>) because it's nested inside the entity browser <form method="post">. Entity browser's entity_browser.view.js sets views_instance.$exposed_form to this <div>, then core's method fails.
Steps to reproduce
- Create an entity browser with a view widget that has exposed filters.
- Open the entity browser modal.
- Use any exposed filter and press Search.
- JavaScript error is thrown, AJAX request fails.
Proposed resolution
In entity_browser.view.js, override removeExposedFiltersQueryParameters on the views instance before calling attachExposedFormAjax (since it calls the method internally). When $exposedForm is not an HTMLFormElement, collect input names via jQuery's :input[name] selector instead of new FormData(). When it is a real <form>, delegate to core's original method.
Issue fork entity_browser-3582428
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
saidatomComment #3
saidatomComment #5
saidatomComment #6
huzookaPostponing on #3121172: Exposed filters get values from url when ajax is on because it is the ticket which causes this type error and the code there is still the subject of change.
Changed ticket category to "Task" because if there is a bug, then it is caused by a non-BC change in core.