Skip to content

Pager links inside a modal do not open in the modal #7096

@docwilmot

Description

@docwilmot

Description of the bug

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

  • Create a page with a pager
  • Open this page in a modal
  • Click a pager link

Shortcut version if you dont want to create a pager page and a modal, replace the contents of one of the many layout modals with the output of a page with a pager:
I deleted everything in layout_block_configure_form() except return $form and replaced it with:

  • module_load_include('inc', 'installer', 'installer.pages');
  • $form['pager-page'] = installer_browser_page('module');

Then clicking any of the "Configure" dropbuttons on the layouck block page will pop up a modal with a pager.
Remember to reverse this.

Actual behavior

Clicking the pager links refreshes the whole page not the modal content

Expected behavior

The modal should load its content by ajax

Additional information

A View with a pager works fine in modals. Views uses theme_pager as well, but Views JS scans for pager links and adds the AJAX behavior
The following code snippet added to theme_pager_link() will fix this for backdrop modals (but not CKEditor modals):

  if (backdrop_is_dialog()) {
    $attributes += array(
      'class' => array('use-ajax'),
      'data-dialog' => TRUE,
    );
  }

However, CKEditor creates modals with ID #ckeditor5-modal, whereas our use-ajax magic link code is set to open a modal with ID #backdrop-modal. So if you add a non-Views pager to a CKEditor modal and click it, it doesnt re-use the modal but pops open a brand new modal on top of the existing CKEditor modal with a #backdrop-modal ID.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions