Commit e81a3e5b authored by catch's avatar catch
Browse files

Issue #3323574 by lobodakyrylo, the_g_bomb, phthlaap, oily, vinmayiswamy,...

Issue #3323574 by lobodakyrylo, the_g_bomb, phthlaap, oily, vinmayiswamy, smustgrave, codebymikey, lendude: Pager not working correctly in AJAX view with exposed filters

(cherry picked from commit c8c538e7)
parent 12d5165f
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@
      // Remove the question mark and Drupal path component if any.
      queryString = queryString
        .slice(1)
        .replace(/q=[^&]+&?|&?render=[^&]+/, '');
        .replace(/q=[^&]+&?|page=[^&]+&?|&?render=[^&]+/, '');
      if (queryString !== '') {
        // If there is a '?' in ajaxPath, clean URL are on and & should be
        // used to add parameters.
+44 −0
Original line number Diff line number Diff line
@@ -622,3 +622,47 @@ display:
        - user.permissions
      max-age: 0
      tags: {  }
  page_2:
    id: page_2
    display_title: 'test pagination with filter'
    display_plugin: page
    position: 2
    display_options:
      pager:
        type: full
        options:
          offset: 0
          pagination_heading_level: h4
          items_per_page: 2
          total_pages: null
          id: 0
          tags:
            next: 'Next ›'
            previous: ' Previous'
            first: '« First'
            last: 'Last »'
          expose:
            items_per_page: true
            items_per_page_label: 'Items per page'
            items_per_page_options: '2, 5, 10, 25, 50'
            items_per_page_options_all: false
            items_per_page_options_all_label: '- All -'
            offset: false
            offset_label: Offset
          quantity: 9
      defaults:
        pager: false
      display_description: ''
      display_extenders: { }
      path: test-content-ajax-filter
    cache_metadata:
      max-age: 0
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - url.query_args
        - user
        - 'user.node_grants:view'
        - user.permissions
      tags: { }
+18 −0
Original line number Diff line number Diff line
@@ -254,4 +254,22 @@ protected function assertNoDuplicateAssetsOnPage(): void {
    }
  }

  /**
   * Tests when a user navigates directly using a page number parameter.
   */
  public function testPaginationAjaxWithTitleFilter(): void {
    // Visit the page url /test-content-ajax-filter?page=3.
    $this->drupalGet('test-content-ajax-filter', ['query' => ['page' => 3]]);
    $session_assert = $this->assertSession();
    $page = $this->getSession()->getPage();

    // Filter by title using the exposed form.
    $session_assert->elementExists('css', 'input[name="title"]')->setValue('Node 11 content');
    $session_assert->elementExists('css', 'input[value="Filter"]')->click();
    $session_assert->assertWaitOnAjaxRequest();

    $rows = $page->findAll('css', 'tbody tr');
    $this->assertStringContainsString('Node 11 content', $rows[0]->getHtml());
  }

}