fix(android): restore unaccepted controlled switch toggles - #154
sbaiahmed1 merged 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough
ChangesControlled BlurSwitch reconciliation
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant NativeSwitch as ReactNativeBlurSwitch
participant Wrapper as BlurSwitchComponent
participant Commands
participant Manager as ReactNativeBlurSwitchManager
NativeSwitch->>Wrapper: onValueChange(nativeValue)
Wrapper->>Wrapper: record nativeValue
Wrapper->>Commands: setNativeValue(nativeRef, value)
Commands->>Manager: setNativeValue(viewRef, value)
Manager->>NativeSwitch: setValue(value)
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
…-android-switch # Conflicts: # src/BlurSwitch.tsx # src/ReactNativeBlurSwitchNativeComponent.ts # website/src/content/docs/migration.mdx
Fix
Add a Fabric setNativeValue command and restore the supplied value when the parent does not accept a native toggle. Record each event, including repeated rejected toggles, and leave accepted updates alone.
Compatibility / breaking changes
Behavior change: Android callers relying on an uncontrolled-looking switch must store value and update it in onValueChange. Omitting value keeps the switch off. This matches the existing iOS/web controlled Switch contract; public prop signatures are unchanged.
Verification
Actual React wrapper with a native-state/command double: absent and ignored handlers fail on baseline and restore correctly after the fix; repeated rejected toggles restore each time, accepted toggles issue no reset command. Generated native command and Kotlin manager compile against RN 0.87.1.
Combined review branch: 40 existing Jest tests across four suites, TypeScript, ESLint (three pre-existing inline-style warnings), Bob builds, web-entry graph validation and whitespace checks passed. No checked-in tests/specs were added or changed. Consumer integration passed both products’ Android Debug and iOS Simulator Debug builds, four production Metro bundles, 13 web targets and four browser-extension targets. The upstream example built for Android and iOS, exported for web, and its iOS home screen was launched and visually inspected. Physical-device, signed-release and Android runtime testing were not performed.
Closes #139
Summary by CodeRabbit
Bug Fixes
Documentation
BlurSwitchis controlled on every platform.valuefromonValueChangeto accept user toggles.