Views exposed form block filters have duplicate IDs when shown on the same Views page

Created on 18 September 2024, 4 months ago
Updated 19 September 2024, 4 months ago

Problem/Motivation

Views exposed forms are always processed even if they're set to be rendered as a block.

Steps to reproduce

Create a view page with an exposed form that's rendered as a block on the same view page .

The exposed form is always processed twice whenever the view in question is built, once in the page, and a second time when the block itself is built.

The version used in the page is unused, but still has Html::getUniqueId() called on all its elements by the form builder, which results in the IDs of the actual exposed form having a --2 suffix attached since it's no longer seen as unique.

Proposed resolution

The documentation of the ViewExecutable::$exposed_widgets property states that:

In cases that the exposed form is rendered as a block this will be an empty array.

So, I'd assume the method should simply return an empty array under the appropriate circumstances rather thann waste resources building the form when it's not actually used on the page.

Remaining tasks

Provide issue fork, and ensure the change in itself doesn't break any existing tests.

User interface changes

N/A

API changes

TBD

Release notes snippet

TBD

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated 32 minutes ago

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024