Enable bookmarking of AJAX views

Created on 6 December 2008, about 16 years ago
Updated 11 July 2024, 6 months ago

Currently we don't track the state of AJAX views. Users trigger reloads, but no state information is logged. Specifically, it is not possible for users to return to a particular state, short of repeating the steps to get there (e.g., load page, click a particular pager link).

Ideally we'd have full browser history support, but that's difficult given the state of jQuery history plugins (sketchy).

An interim approximation would be:

* set a URL fragment when loading by AJAX
* on initial page load, look for a fragment and, finding one, load it.

Feature request
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated about 5 hours ago

Created by

🇨🇦Canada nedjo

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France prudloff Lille

    Here is a reroll for Drupal 10.0.

  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

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

  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India pooja saraah Chennai

    Fixed failed commands on #70
    Attached patch against Drupal 10.1.x

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States webdrips

    Re-rolling #65 for 9.5.9

  • last update over 1 year ago
    Custom Commands Failed
  • 🇧🇾Belarus kachinsky

    Hi @webdrips
    Your patch doesn't work, the view returns the error after applying:
    Error: Class "Drupal\views\Ajax\SetBrowserUrl" not found in Drupal\views\Controller\ViewAjaxController->ajaxView() (line 219 of /code/web/core/modules/views/src/Controller/ViewAjaxController.php)

  • 🇮🇳India shabana.navas

    Is there a quick way we can clean up the URL that is built? Right now, I only have a couple of exposed filters and the URL already looks like this: ?date%5Bmin%5D%5Bdate%5D=2023-05-29&date%5Bmax%5D%5Bdate%5D=2023-06-16&promotion_type%5B6%5D=6&promotion_type%5B1%5D=1

  • 🇫🇷France prudloff Lille

    #72 does not apply to 10.1.0. Here is a reroll.

    (I tried to generate an interdiff but it fails for some reason.)

  • 🇰🇬Kyrgyzstan elaman

    The most recent patch causes a bug if user visits bookmarked url and tries to uncheck the existing filter. The main reason is that queryString is preserved when performing request to the ajax callback page:

        this.element_settings = {
          url: ajaxPath + queryString,
          submit: settings,
          httpMethod: 'GET',
          setClick: true,
          event: 'click',
          selector,
          progress: { type: 'fullscreen' },
        };
    

    So you can't really reset bookmarked filters.

    Also it is better to push new filter state into history, so you can use browser navigation to restore previous filter state.

  • 🇰🇬Kyrgyzstan elaman

    Instead of removing queryString that caused issues, now remove only params that represent exposed filters.

  • 🇫🇷France prudloff Lille

    #82 causes a problem with pagination, for example :

    1. Check a filter that returns 3 page of results.
    2. Browse to page 3.
    3. Check another filter that only has one page of results.
    4. The view stays on page 3 and displays no result.

    Remove the page param from the query string seems to fix it.

  • 🇫🇷France prudloff Lille

    Here is a reroll of #83 for Drupal 10.2.

  • First commit to issue fork.
  • 🇮🇳India sakthi_dev

    sakthi_dev changed the visibility of the branch 10.0.x to hidden.

  • 🇮🇳India sakthi_dev

    Re rolled with 11.x.

  • 🇫🇷France GaëlG Lille, France

    GaëlG made their first commit to this issue’s fork.

  • Merge request !7074Draft: Resolve #343535 "11.x" → (Open) created by GaëlG
  • Pipeline finished with Failed
    9 months ago
    Total: 206s
    #122230
  • Pipeline finished with Failed
    9 months ago
    Total: 174s
    #122253
  • Pipeline finished with Failed
    9 months ago
    #122302
  • 🇫🇷France GaëlG Lille, France

    I made a fix so that browser URL is not updated if the view is in a dialog/modal, because in that case the browser URL is not the URL containing the view parameters.
    It's like there's an URL for the page which is behind the modal (the one shown in the browser URL field), and one other URL ("hidden") for the "page" shown in the modal.
    Without this fix, we got a strange behavior when using media library search in modal: it works the first time, but as soon as params are added to the browser URL, subsequent search is buggy until the whole page is reloaded.
    I guess a test should be added for the modal case? Like just test that browser URL is not updated when an AJAX exposed form is used inside a modal.

    And automated tests do not pass, I guess it's just some test code that needs to be updated for compatibility with current 11.x.

    Then, I believe the merge request will be ready for review again.

  • Pipeline finished with Failed
    9 months ago
    Total: 585s
    #141660
  • First commit to issue fork.
Production build 0.71.5 2024