refactor(webapp): derive controlled UI state during render - #4726
refactor(webapp): derive controlled UI state during render#4726carderne wants to merge 1 commit into
Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
| // Reset the bundle stepper to the user's current extra-schedules count on each open. | ||
| const handleOpenChange = (nextOpen: boolean) => { | ||
| if (nextOpen) setBundles(Math.round(extraSchedules / stepSize)); | ||
| setOpen(nextOpen); | ||
| }; |
There was a problem hiding this comment.
🟡 Extra-schedules purchase dialog can show an outdated bundle count
The bundle stepper is now only reset when the dialog is opened (handleOpenChange at apps/webapp/app/components/schedules/PurchaseSchedulesModal.tsx:71-74) and no longer re-syncs while it is open, so a user can see a bundle count that disagrees with the current extra-schedules figure shown right next to it.
Impact: Right after a purchase, reopening the dialog before the refreshed numbers arrive shows a stale bundle count that never corrects itself until the dialog is closed and opened again.
Loss of prop-driven re-sync when extraSchedules/stepSize change while open
The removed effect had [open, extraSchedules, stepSize] as dependencies, so it reset bundles both on open and whenever the props changed (e.g. after the purchase action triggers a loader revalidation that updates extraSchedules). The replacement only resets inside handleOpenChange when nextOpen is true. If the dialog is opened while extraSchedules is still the pre-purchase value and the revalidated value arrives afterwards, bundles (and therefore amountValue) stays stale while the summary section renders the fresh extraSchedules (apps/webapp/app/components/schedules/PurchaseSchedulesModal.tsx:181-213), producing an inconsistent diff/total. A cheap fix is to keep resetting when extraSchedules/stepSize change (e.g. a key-reset or an effect scoped to prop changes) in addition to the on-open reset.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Derives controlled tab, tag, and checkbox values directly during render instead of copying them through effects. Modal drafts now reset from their open event, and the route-backed alert dialog renders open immediately without a mount-time state update.