Files
TiddlyWiki5/core/modules/widgets
Mario PietschandGitHub 94b046b8cb Fix button widget selection state with setTitle (#9951)
Make the button widget apply selectedClass correctly when the state is
addressed with setTitle instead of set.

Issue #9949, the button could not be rendered at all

* Guard the setField read in isSelected(), which dereferenced the result of
  getTiddler() directly. A missing state tiddler threw a TypeError, and that
  tiddler is normally only created by the first click

Issue #9950, every button of a set reported itself as selected

* Rewrite isSelected() as an if/else. The nested ternary mixed `||` with
  `?:`, so the setTitle branch returned a fallback value instead of a
  comparison
* Watch the setTitle state tiddler in refresh(), so the selected class
  follows the state as it already does for set

Documentation and tests

* Document that setField takes preference over setIndex. That has always
  been the behaviour, it was never written down
* Document that selectedClass and default apply to setTitle as well as to set
* Add wiki based test cases for the set, setTitle, setField and setIndex
  selection paths. Six of the seven fail against v5.4.1, the one that passes
  uses set, which was never broken

Fixes #9949
Fixes #9950
2026-07-28 11:19:12 +01:00
..
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-10 12:16:20 +01:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00
2026-02-20 08:38:42 +00:00