Skip to content

fix: make Trust toggle a controlled component#345

Merged
calvadev merged 1 commit intoshopstr-eng:mainfrom
23bsm038-Mahi:fix/trust-toggle-controlled-clean
Apr 6, 2026
Merged

fix: make Trust toggle a controlled component#345
calvadev merged 1 commit intoshopstr-eng:mainfrom
23bsm038-Mahi:fix/trust-toggle-controlled-clean

Conversation

@23bsm038-Mahi
Copy link
Copy Markdown
Contributor

Summary

Make the Trust toggle a controlled component by binding it to the existing wotFilter state.

Problem

The Trust filter switch was updating state on interaction but was not receiving the current state as a prop. This could cause the UI to become out of sync with the actual filter state after re-renders.

Changes

  • Added isSelected={wotFilter} to the Switch component
  • Replaced onClick with onValueChange for proper controlled behavior

Why this matters

Ensures the toggle UI always reflects the actual filter state, improving reliability and user experience.

Scope

  • One-file, minimal UI change
  • No changes to filtering logic
  • Fully backward compatible

Testing

  • Verified that toggle state stays consistent after interactions and re-renders

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

@23bsm038-Mahi is attempting to deploy a commit to the shopstr-eng Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@kaihere14 kaihere14 left a comment

Choose a reason for hiding this comment

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

Nice job. Switching from onClick to onValueChange is right, because onClick is not getting the new boolean value so the toggle was just being uncontrolled. When binding isSelected to {wotFilter}, it makes sure that the UI will reflect the actual state. Nicely solved.

@GautamBytes
Copy link
Copy Markdown
Contributor

LGTM

@calvadev calvadev merged commit 28a20bc into shopstr-eng:main Apr 6, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants