Pager links inside a modal do not open in the modal

Created on 26 March 2020, over 4 years ago
Updated 14 May 2024, about 1 month ago

Problem/Motivation

If a pager is rendered within a modal, the pager links do not contain relevant ajax attributes therefore breaking out of the modal when clicked.

Steps to reproduce

  1. Create a custom route with a pager
  2. Create a route with a link to open the route in step 1 in a modal
  3. Open the modal, click a pager link
  4. Expected to see that page in the modal, but page is reloaded with ajax params rendered.

Proposed resolution

Add ajax/dialog options to pager when inside a modal.

Remaining tasks

Agree on approach
Tests
Review

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Ajax 

Last updated 1 minute ago

Created by

🇦🇺Australia dpi Perth, Australia

Live updates comments and jobs are added and updated live.
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.

  • 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 over 1 year ago
  • 🇦🇺Australia acbramley

    Rebased onto an MR and added additional tests.

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

    So using views_test_modal module from core
    When I click the link (which has class use-ajax)
    Modal opens
    Clicking a page items renders some errors

    Applying the patch

    I get the same results.

    Using content view with ajax turned off ( as the issue summary didn't mention turning it on)

  • 🇫🇮Finland lauriii Finland

    Posted review on the MR

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    29,438 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    29,573 pass
  • 🇦🇺Australia acbramley

    Rebased onto 11.x and changed target. There was a conflict with 10.1.x that needed resolving first. Thanks to @larowlan for helping with the git foo.

  • last update 11 months ago
    29,948 pass
  • last update 9 months ago
    30,381 pass
  • Pipeline finished with Success
    9 months ago
    Total: 785s
    #26968
  • 🇮🇹Italy maurizio.ganovelli Arezzo

    Using only this condition:
    \Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT) === 'drupal_modal'
    seems to fail in some use cases.
    I have a modal form with ajax submit and tableselect element with pager. Applying this patch, pager links get ajaxified and work well until a validation error occurs. During submit, request wrapper format is "drupal_ajax", so after validation fails condition does not pass and links don't have use-ajax class and data attributes anymore.
    Adding this:
    in_array(\Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT), ['drupal_ajax', 'drupal_modal'])
    make pager work also after a failed validation, but i don't know if this can have unwanted side effects.

  • Pipeline finished with Failed
    6 months ago
    Total: 174s
    #74576
  • Pipeline finished with Success
    6 months ago
    Total: 563s
    #74577
  • Pipeline finished with Failed
    6 months ago
    Total: 746s
    #74580
  • Pipeline finished with Success
    6 months ago
    Total: 567s
    #74585
  • 🇫🇷France rkcreation

    Tested with Drupal 10.2.6, it works well with pager inside modal and without views. I use pager render array like this :

    [
            '#type' => 'pager',
            '#route_name' => '<current>',
    ]
  • First commit to issue fork.
  • 🇮🇳India sakthi_dev

    Rebased and resolved the conflicts.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 176s
    #172673
Production build 0.69.0 2024