Problem/Motivation

Based on #343535: Enable bookmarking of AJAX views and https://www.drupal.org/node/3552223, it appears that starting with Drupal 11.3.x, the AJAX Views bookmarking functionality in the core/views module is enabled by default and cannot be disabled.

There are scenarios where disabling this functionality would be desirable. For example, a page may contain multiple View blocks with AJAX enabled and exposed filters. Because bookmarking is always enabled, each interaction can add additional query parameters to the URL. This can result in excessively long and cluttered URLs, which may be undesirable in some cases. In other situations, the bookmarking functionality may simply not be needed, and simpler URLs would be preferred.

In addition, the current bookmarking implementation has been reported to cause issues, as noted in https://www.drupal.org/project/drupal/issues/343535#comment-16579695.

Steps to reproduce

  • Create a View block with an exposed form (including at least one exposed filter) and enable AJAX.
  • Place the block on a page.
  • Apply a filter using the exposed form and observe that the URL is updated with query parameters.
  • Note that there
  • is currently no setting or configuration option to disable this behavior.

    Proposed resolution

    Allow the AJAX Views bookmarking functionality to be enabled or disabled through the View's configuration settings.

    Here are some screenshots of the proposed solution from MR #16252:

    The new disable AJAX option appears when AJAX is used in the view.

    The new disable AJAX option appears when AJAX is used in the view

    The option opens a dialog to disable AJAX URL rewriting.

    The option opens a dialog to disable AJAX URL rewriting.

    Remaining tasks

    Issue fork drupal-3604351

    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

    takkuyu created an issue. See original summary.

    takkuyu’s picture

    Title: Allow disabling of bookmarking of AJAX views » Allow disabling bookmarking for AJAX Views
    Issue summary: View changes
    takkuyu’s picture

    Patch file #1 has been created which removed the new SetBrowserUrl to disable the view ajax bookmarking (just a temporary patch to force it disabled)

    takkuyu’s picture

    Issue tags: -JavaScript +JavaScript
    StatusFileSize
    new1.18 KB
    cilefen’s picture

    Status: Active » Needs work
    Issue tags: -JavaScript, -views exposed filters +Needs merge request
    quietone’s picture

    Version: 11.x-dev » main
    Issue summary: View changes
    Issue tags: -Ajax
    Parent issue: #343535: Enable bookmarking of AJAX views »
    Related issues: +#343535: Enable bookmarking of AJAX views

    Hi, Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.

    ishani patel made their first commit to this issue’s fork.

    marcoliver made their first commit to this issue’s fork.

    marcoliver’s picture

    Status: Needs work » Needs review

    I added an MR with a proposed solution. As suggested in the issue description, it adds another checkbox allowing you to disable the AJAX bookmarking feature. If the value is true, views AJAX responses will skip the "add to browser URL" step.

    I also added another test to ExposedFilterAjaxTest.

    Probably not the final word on this, but it might be a start.

    needs-review-queue-bot’s picture

    Status: Needs review » Needs work
    StatusFileSize
    new1.19 KB

    The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

    marcoliver’s picture

    Status: Needs work » Needs review

    Moving back to Needs review.

    The bot flagged an unused use statement in the older MR. Pushed a change there to get the bot off my case.

    marcoliver’s picture

    smustgrave’s picture

    Status: Needs review » Needs work

    Appears to have 2 MRs can one be closed or hidden please.

    Also sounds like something that may need test coverage.

    Can screenshots of the new configuration be added to the summary too.

    marcoliver changed the visibility of the branch 3604351-allow-disabling-bookmarking to hidden.

    marcoliver changed the visibility of the branch main to hidden.

    marcoliver’s picture

    marcoliver’s picture

    Issue summary: View changes
    marcoliver’s picture

    Issue summary: View changes

    No problem!

    The old MR is hidden now.

    Currently there is one new test, basically the reverse situation of the AJAX form filter test introduced in the previous issue. If more tests are needed, I'm certainly open to suggestions!

    Finally, added some screenshots of where the new option would pop up using the MR. Updated issue summary accordingly.

    marcoliver’s picture

    Status: Needs work » Needs review
    marcoliver’s picture

    Issue summary: View changes
    smustgrave’s picture

    Status: Needs review » Needs work
    Issue tags: -Needs merge request +Needs Review Queue Initiative

    Thanks for keeping it going, left a comment on the MR.

    marcoliver’s picture

    Status: Needs work » Needs review

    I updated the MR. It now contains an upgrade path via ViewsConfigUpdater, kernel tests for the updated updater, and a functional update test.

    needs-review-queue-bot’s picture

    Status: Needs review » Needs work
    StatusFileSize
    new91 bytes

    The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

    marcoliver’s picture

    Status: Needs work » Needs review

    Rebased, patch should apply again.