View where input is required, ajax enabled and full text exposed search is empty does not show results on pagination

Created on 15 July 2019, almost 5 years ago
Updated 31 January 2024, 5 months ago

Steps to reproduce

Create a view (page) that:

  1. Has an exposed search input
  2. Ajax is enabled
  3. Exposed form style is Input required

Expected behaviour

When performing an empty search to get all results, using the pagination to go to the next page should display the second page results.

Actual behaviour

The second page does not show any results. Instead, the view displays as it would when first visiting the page.

Problem and possible solution

The Drupal.Views.parseQueryString function in base.js does not return an argument if its value is an empty string. Therefore, when performing an empty search and navigating to the second page results, the empty search query is removed from the parameters and displays the view with no results.

The culprit is this portion of code:

if (pair[0] !== 'q' && pair[1]) {
        args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
}

Because the value of pair[1] is an empty string, the argument does not get added to the args array.

A possible fix could be changing the statement to check if pair[1] !== 'undefined' and this would allow for empty strings. However, I'm unsure of all the potential use cases and unsure if this would invalidate a use case that I'm unaware of.

πŸ› Bug report
Status

Closed: duplicate

Version

9.5

Component
ViewsΒ  β†’

Last updated 32 minutes ago

Created by

πŸ‡¨πŸ‡¦Canada nedga055

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

Comments & Activities

Not all content is available!

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

Production build 0.69.0 2024