Skip to content

Fix tabs and applies-switch in snippets - #2340

Merged
reakaleek merged 1 commit into
mainfrom
feature/fix-tabs-applies-switch-in-snippets
Dec 11, 2025
Merged

reakaleek merged 1 commit into
mainfrom
feature/fix-tabs-applies-switch-in-snippets

Conversation

@reakaleek

@reakaleek reakaleek commented Dec 11, 2025 •

Copy link
Copy Markdown
Member

Closes #2334

Problem

When the same snippet containing applies-switch or tab-set is included multiple times on a page, the generated HTML IDs are duplicated. This causes radio buttons to conflict with each other, breaking the UI.

Solution

Track the line number of each include directive and use it to generate unique IDs.

Formula: (include_line × 1000) + snippet_line

Example: A snippet included at line 5 with an applies-switch at line 3 gets ID 5003.

Changes

  • Added IncludeLine property to ParserContext to track where snippets are included
  • Added GetUniqueLineIndex() helper in DirectiveBlock base class
  • Updated TabSetBlock and AppliesSwitchBlock to use the new helper
  • Added tests for both single and multiple includes

@reakaleek reakaleek added the fix label Dec 11, 2025
@reakaleek reakaleek self-assigned this Dec 11, 2025
@reakaleek
reakaleek marked this pull request as ready for review December 11, 2025 12:36
@reakaleek
reakaleek requested review from a team as code owners December 11, 2025 12:36
@reakaleek
reakaleek requested a review from cotti December 11, 2025 12:36
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Preview links for changed docs

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clever :)

@reakaleek
reakaleek merged commit 86ed9ed into main Dec 11, 2025
@reakaleek
reakaleek deleted the feature/fix-tabs-applies-switch-in-snippets branch December 11, 2025 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Same applies switch used twice through a snippet is not rendered properly

2 participants