Skip to content

Tabs-macro-fallback-fix-6548#9751

Open
pmario wants to merge 9 commits intoTiddlyWiki:masterfrom
pmario:tabs-macro-fallback-fix-6548
Open

Tabs-macro-fallback-fix-6548#9751
pmario wants to merge 9 commits intoTiddlyWiki:masterfrom
pmario:tabs-macro-fallback-fix-6548

Conversation

@pmario
Copy link
Copy Markdown
Member

@pmario pmario commented Mar 17, 2026

PR: Add validValues attribute to button and reveal widgets (#6548)

Problem

When a tab is removed but its state tiddler retains the stale identifier, no tab button appears selected and no tab body is revealed — the user sees a blank panel.

Solution

Both <$button> and <$reveal> now accept a validValues attribute containing a filter expression. If the current state value is not in the evaluated results, the widget falls back to default. Using a filter is essential because tabsList is typically a filter like [tag[$:/tags/SideBar]].

The tabs macro passes validValues=<<__tabsList__>> to its button and reveal widgets automatically — no end-user changes needed.

Additional fixes

  • isSelected() refactoring — The original nested ternary with || fallback made isSelected() truthy for all buttons when using setTitle + setField/setIndex with a default. Now uses strict currentValue === this.setTo.
  • Button refresh fix — Added changedTiddlers[this.setTitle] check so setTitle-based buttons re-render on state changes.

Files changed

File Change
core/modules/widgets/button.js validValues, refactored isSelected(), refresh fix
core/modules/widgets/reveal.js validValues fallback in readState()
core/wiki/macros/tabs.tid Pass validValues=<<__tabsList__>>
editions/tw5.com/.../ButtonWidget.tid Docs
editions/tw5.com/.../RevealWidget.tid Docs

Tests (13 button + 1 tabs integration)

Test Mechanism State validValues Expected
ValidState set valid yes Correct selected
InvalidState set invalid yes Default selected
NoState set missing yes Default selected
NoValidValues set valid no Correct selected
NoValidValuesInvalidState set invalid no None selected
NoValidValuesNoState set missing no Default selected
FilterValidValues set invalid filter Default selected
SetTitle{Valid,Invalid}State setTitle both yes As expected
SetField{Valid,Invalid}State setField both yes As expected
SetIndex{Valid,Invalid}State setIndex both yes As expected

All test cases use compound tiddlers, manually importable into a wiki for visual verification.

fixes: #6548

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 17, 2026

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit 68037d9
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/69b98b4642c6be0008e0043b
😎 Deploy Preview https://deploy-preview-9751--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown

Confirmed: pmario has already signed the Contributor License Agreement (see contributing.md)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2487.2 KB
PR 2488.5 KB

Diff: ⬆️ Increase: +1.3 KB


⚠️ Change Note Status

This PR appears to contain code changes but doesn't include a change note.

Please add a change note by creating a .tid file in editions/tw5.com/tiddlers/releasenotes/<version>/

📚 Documentation: Release Notes and Changes

💡 Note: If this is a documentation-only change, you can ignore this message.

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.

[BUG] tabs-macro should fall back to "default" tab if state-tiddler exists, but contains an invalid value

1 participant