Conversation
|
Skipping CI for Draft Pull Request. |
|
Images are ready for the commit at 0334f54. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18411 +/- ##
=======================================
Coverage 48.93% 48.94%
=======================================
Files 2631 2631
Lines 197964 197964
=======================================
+ Hits 96872 96886 +14
+ Misses 93703 93695 -8
+ Partials 7389 7383 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
af9c748 to
edf68e6
Compare
|
Tests should be resolved once #18422 goes in. The reason is explained in this comment: #18422 (comment) |
Use functional updater (prev) => !prev for all boolean toggles to prevent stale closure bugs and handle rapid state changes correctly. Updated 37 files across hooks, components, and containers. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
dvail
left a comment
There was a problem hiding this comment.
🎉
These props accept only boolean values, not functional updaters. Changing them would require updating parent component type contracts.
Certainly not something that we should do in this PR, but I don't think updating the type contracts should be a blocker to change the other instances of this. (Other than the blocker of it being more cleanup work.)
Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
Description
Standardized the boolean toggle state updater pattern across the UI codebase to use the functional updater form
setState((prev) => !prev)instead of the direct value formsetState(!value).This follows React's recommended pattern when new state depends on previous state, preventing stale closure bugs and correctly handling rapid state changes (e.g., multiple rapid clicks).
Key Changes:
(prev) => !prevpatternTypeScript Constraint Exceptions:
Two files retained the direct value pattern due to TypeScript prop constraints:
FlowBulkDropdown.tsx-setOpenprop typed as(o: boolean) => voidCreateViewBasedReportModal.tsx-setIsOpenprop typed as(value: boolean) => voidThese props accept only boolean values, not functional updaters. Changing them would require updating parent component type contracts.
User-facing documentation
Testing and quality
Automated testing
How I validated my change