Problem/Motivation

The ajax improvements in the 3.x branch of Facets are super awesome and super appreciated. It feels like we can take it to the next level (performance-wise) by adding GET support. When the views plugin support was initially added in #3073444: Create views plugins to render facets and summaries in filters and areas this was done through the views_ajax_get module. It looks like when ajax support was improved with BEF in #3306634: Integrate with better_exposed_filters for AJAX, the views_ajax_get integration was dropped.

Proposed resolution

My hope is to add that integration back here. Eventually when #956186: Allow AJAX to use GET requests lands we can drop the integration once again.

Remaining tasks

Create a patch that adds views_ajax_get integration.

User interface changes

None

API changes

None

Issue fork facets-3343860

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

malik.kotob created an issue. See original summary.

malik.kotob’s picture

Issue summary: View changes

Slight tweaks to issue summary.

malik.kotob’s picture

Issue summary: View changes

Updating issue summary to reference issue and Gitlab MR that removed GET support.

malik.kotob’s picture

Merge request is up!

Requires contrib modules to test:

  • Facets
  • better exposed filters
  • views_ajax_get

Testing steps:

  1. Enable the required contrib modules
  2. Login to your site
  3. Visit /admin/structure/views/settings/advanced and enable views_ajax_get extender
  4. Create a view with ajax and GET requests enabled
  5. Setup checkbox facets to associate with the new view
  6. Edit the view to add the newly created facets as filters through the facets views plugin integration
  7. Edit the view to enable better exposed filters, ideally with auto-submit enabled
  8. Save the view settings
  9. Test the view and request type by filtering with the facets and observing the network tab in your browser's debugger
  10. Verify you're seeing GET requests instead of POST
  11. Edit the view's ajax settings to disable GET requests
  12. Save the view settings
  13. Test the view with your network tab and verify you're now seeing POST requests (you may need to clear caches)
malik.kotob’s picture

Status: Active » Needs review
mkalkbrenner’s picture

Status: Needs review » Needs work

I think we should create a sub-module facets_ajax that has dependencies to better_exposed_filters and views_ajax_get.
In facets itself we should throw an exception if a view uses ajax and a facet gets rendered without facets_ajax beeing active.

catch’s picture

#956186: Allow AJAX to use GET requests landed in 10.1.x, is some of this needed to work with the core change now?

smustgrave’s picture

Category: Feature request » Bug report
Priority: Normal » Critical

Changing this to a bug now.

When using facets 3.0.x all ajax paginations are now broken.

Steps to reproduce
Install facets
Edit admin/content view by enabling ajax
Add enough content or edit view to trigger pagination.
Pagination no longer works.

Can also be seen in the media library widget.

Applying the MR resolved the problem.

catch’s picture

Title: Improve ajax performance by adding GET support via views_ajax_get module » Support views AJAX GET requests after https://www.drupal.org/project/drupal/issues/956186 / 10.1.x

Updating the issue title. The RouteAlterSubscriber probably won't be necessary to add support for views_ajax_get any more (since that module should hopefully be deprecated from 10.1.x onwards), but most/all the rest of the changes look generic to support AJAX GET requests at all.

marios anagnostopoulos’s picture

@mkalkbrenner I guess the approach should change now since the views_ajax_get is redundant?

Then again how would we handle BC for < 10.1.x sites?

mkalkbrenner’s picture

pjotr van der horst’s picture

I've added 93689d9ca1faadfbc7ef52f951dc4528847c300d.patch to this issue.

This patch contains the current state of the merge request. See "Patches from drupal.org merge request URLs are dangerous?" for more information.

pjotr van der horst’s picture

I've used a filename that was not websafe. My bad. I can't delete my previous comment. here is the patch with the commit hash as filename.
This patch contains the current state of the merge request. See "Patches from drupal.org merge request URLs are dangerous?" for more information.

strykaizer’s picture

Status: Needs work » Closed (won't fix)

In Facets 3 we removed all ajax support for facets as blocks, see #3379445: Facets breaks all AJAX views that uses pagers even without facets

You can use Facets Exposed Filters if you need AJAX support, which uses GET requests.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.