[Bug]: .isSwitched of a Switch-widget doesn't get the correct (updates) value
Is there an existing issue for this?
- [x] I have searched the existing issues
Description
Steps To Reproduce
- Click 2 (or more) times on ToggleButton (note: one click seems mostly to work fine)
- The Switch-widget is updates correctly and also the (depending) MyButton is updated correctly (with disabled true or false)
- Click once on Switch-widget
- The switch-widget changes of course correct, BUT the (depending) MyButton is NOT updated correctly (with disabled true or false)
- I checked: the reason is on line 8: Switch.isSwitched doesn't have the correct value
Public Sample App
No response
Environment
Production
Severity
Medium (Frustrating UX)
Issue video log
No response
Version
Docker self-hosted, Appsmith v1.95 2 jan 2026
Proposed fix
Root cause: SwitchWidget stores isSwitchedOn as a meta property that defaults to defaultSwitchState. Once the user interacts with the Switch, the meta value takes precedence. Subsequent external changes to defaultSwitchState (e.g. via Switch1.setValue(...) driven by a ToggleButton) update defaultSwitchState but leave the stale meta isSwitchedOn in place, so widgets bound to Switch1.isSwitchedOn keep reading the old value.
The sibling CheckboxWidget already handles this in componentDidUpdate by syncing the meta when the derived value changes (app/client/src/widgets/CheckboxWidget/widget/index.tsx). SwitchWidget is missing the equivalent block.
Planned PR
- Add a programmatic-change sync in
SwitchWidget.componentDidUpdatesoisSwitchedOnmeta stays consistent whendefaultSwitchStatechanges externally. - Add/extend tests covering the ToggleButton → Switch → dependent-widget chain.
File touched
app/client/src/widgets/SwitchWidget/widget/index.tsx
Happy to take this on will open a PR.