Use filter identifier when building views preview URL

Created on 21 July 2023, over 1 year ago
Updated 23 April 2024, 8 months ago

Problem/Motivation

jsonapi_views_views_preview_info_alter() is checking for exposed filters by field name instead of by identifier.

When previewing a JSON:API Views -enabled view with an exposed filter, the log shows warnings like the following for each exposed filter:

Warning: Undefined array key "created" in jsonapi_views_views_preview_info_alter() (line 43 of web/modules/contrib/jsonapi_views/jsonapi_views.module)

Steps to reproduce

  1. Create a view on nodes and ensure that "Exposed via JSON:API" is set to "Yes".
  2. Add a filter on a node field, make it exposed, and set its [required] "Filter identifier".
  3. Preview the view below.

The filter won't show up in the URL in the "JSON:API Views", and there will be a warning like the above in the site log.

Proposed resolution

Check for filter identifier instead of just field name.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jeffschuler Boulder, Colorado

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024