Skip to content

Test the QR dialog id fix from #1688 - #1694

Merged
wen-2018 merged 1 commit into
mainfrom
janriokrause/unique-qr-dialog-ids
Aug 7, 2026
Merged

wen-2018 merged 1 commit into
mainfrom
janriokrause/unique-qr-dialog-ids

Conversation

@janriokrause

Copy link
Copy Markdown
Contributor

Summary

Test the duplicate QR dialog id fix from #1688.

Significant changes and points to review

  • The test: Renders TabsBlock with referral controls in two tabs, the case WT-1476 Ff referral hug page styling #1688 fixed. It pairs each trigger with the dialog in its own panel, because comparing two document-order lists passes even when the ids are duplicated. Mutation-tested against a static controls_id and against a cross-wired data-target-id.

  • is defined guard: The riskiest part to review, and the only change no test covers. tabs.html numbers tabs with loop.index, so the old truthiness check worked only because that index is 1-based. loop.index0 would have collapsed tab 0 of every tabs section onto one shared id.

  • Shorter dialog id: Now fl-referral-controls-hub-1-qr-dialog. Referenced nowhere outside the template, not in CSS, JS, or tests.

  • _referral_controls_stream: Replaces five copies of the StreamBlock wire format in the tests. Mechanical.

Context

Referral controls can render in several tabs, and a dialog trigger
resolves its target with `getElementById`. #1688 made the ids unique
but left the two-tab case uncovered.

* Guard `controls_id` on `is defined` rather than truthiness, so a
  switch to `loop.index0` cannot put tab 0 back on the fallback id.
* Drop the duplicated prefix from the dialog id suffix.
* Extract `_referral_controls_stream` in the tests.
@janriokrause
janriokrause requested review from wen-2018 and a lite review from Copilot August 6, 2026 18:29
@janriokrause janriokrause self-assigned this Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a regression test to ensure each tab’s referral-controls QR dialog has a unique DOM id (preventing getElementById from binding all triggers to the first dialog), and updates the templates to generate safer, shorter dialog ids and more robust per-tab namespacing.

Review performed following the repository’s custom Copilot instructions (including AGENTS.md and the referenced platform code-review checklists).

Changes:

  • Add a TabsBlock-level test that verifies each tab’s QR trigger targets the dialog within its own panel (catching duplicate ids).
  • Shorten the QR dialog id suffix in the referral-controls component to reduce redundancy while preserving uniqueness via the parent id.
  • Make the referral-controls block’s controls_id conditional robust to a future tab_index=0 scenario by checking is defined instead of truthiness.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
springfield/cms/tests/test_blocks.py Adds a TabsBlock regression test for per-tab QR dialog id uniqueness; refactors test stream construction via _referral_controls_stream.
springfield/cms/templates/components/referral-controls.html Shortens the internal QR dialog id suffix to -qr-dialog while keeping trigger/dialog wiring consistent.
springfield/cms/templates/cms/blocks/referral-controls.html Updates controls_id generation to avoid collapsing ids if tab_index ever becomes 0 (e.g., with loop.index0).

Comment on lines +13 to +18
{#
The id namespaces this instance's dialog, so it has to differ per tab. It tests
`is defined` rather than truthiness so that switching `tabs.html` to
`loop.index0` cannot silently drop the first tab onto the fallback id.
#}
{% set controls_id = ('fl-referral-controls-' ~ section_id ~ '-' ~ tab_index) if section_id is defined and tab_index is defined else 'fl-referral-controls' %}
@wen-2018
wen-2018 merged commit 589ed3b into main Aug 7, 2026
1 check passed
@wen-2018
wen-2018 deleted the janriokrause/unique-qr-dialog-ids branch August 7, 2026 12:21
bluewave41 pushed a commit that referenced this pull request Sep 22, 2026
Referral controls can render in several tabs, and a dialog trigger
resolves its target with `getElementById`. #1688 made the ids unique
but left the two-tab case uncovered.

* Guard `controls_id` on `is defined` rather than truthiness, so a
  switch to `loop.index0` cannot put tab 0 back on the fallback id.
* Drop the duplicated prefix from the dialog id suffix.
* Extract `_referral_controls_stream` in the tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants