fix: applies-switch and tab-set first tab hidden when block contains a comment#3255
fix: applies-switch and tab-set first tab hidden when block contains a comment#3255
Conversation
…b selection
Any non-item block inside {applies-switch} or {tab-set} (e.g. a % comment)
occupies index 0 in the Markdig child list, pushing all {applies-item} /
{tab-item} blocks to indices 1, 2, 3 … The Razor templates use
`Model.Index == 0` to emit `checked="checked"` on the first radio input;
when that condition never fires no tab content is visible on initial load.
Before — broken when a comment precedes the first item:
::::::{applies-switch}
% TODO: update when Cloud UI supports this
:::::{applies-item} ess:
…content…
:::::
::::::{applies-switch}
The first radio renders without `checked`; all tab panels stay hidden
until the user clicks a tab.
After — counts only sibling items, ignoring other block types:
Index = Parent!.OfType<AppliesItemBlock>().ToList().IndexOf(this);
Fixes #3254
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Why
Any non-item block inside
{applies-switch}or{tab-set}— such as a MyST%comment — occupies index 0 in Markdig's child list, pushing all{applies-item}/{tab-item}blocks to indices 1, 2, 3 …The Razor templates use
Model.Index == 0to emitchecked="checked"on the first radio input, which is what the pure-CSS tab mechanism relies on to show the first panel. WhenIndexis never 0, no radio is checked, and all tab content stays hidden until the user clicks a tab.The real-world trigger was a
% TODOcomment in the query-logs source:::::::{applies-switch} % TODO: Update ECH and ECE tabs when Cloud UI supports configuring query logging settings directly. :::::{applies-item} ess: …This caused #3254.
What
Changed
AppliesItemBlockandTabItemBlockto compute their index relative to sibling items only, rather than among all children of the parent block:Added a regression test (
ApplicabilitySwitchWithCommentTests) that places a%comment before the first{applies-item}and asserts both that indices are 0-based and that the first radio renders withchecked="checked".