LF-5219: Incorrect redirect to create farm page after changing password#4120
Conversation
There was a problem hiding this comment.
Ooooh, I would never have come across that on my own or traced the route cause...!
and render
<OnboardingFlow />which doesn't have /password_reset
I'm not great on the logic of the routes files, but you don't think this is also worth fixing on its own, separate from the re-rendering? Am I understanding correctly the re-render exposed a little bit of faulty routing logic in that branch?
And also just checking my understanding that this would be something to watch for as we keep adding custom hooks to App.jsx (as has become a small pattern since the offline release!)... I don't think I was thinking at all about <Routes /> re-rendering when writing selectors in those hooks 🫤
|
@kathyavini You’re right, the same thing happens when you go offline while the modal is shown. |
Description
Fix
Prevent unnecessary Route re-renders when form submissions update Redux state
Problem
When users submit the password reset form (in
/password_reset), the Routes component would unexpectedly re-render and redirect them to/welcome, where they should see a modal and then be redirected to/farm_selection.Root Cause
8bb5402 (Implementing offline navigation logging, v3.10.0 release on Feb 25, 2026)
The
useOfflineActivityLoggerhook was usinguseSelector(userFarmSelector), which subscribes to all changes in theuserFarmRedux state. When the form submission updateduser_id:LiteFarm/packages/webapp/src/containers/PasswordResetAccount/index.jsx
Lines 19 to 22 in 5f2510f
LiteFarm/packages/webapp/src/containers/PasswordResetAccount/saga.js
Lines 28 to 49 in 5f2510f
LiteFarm/packages/webapp/src/containers/userFarmSlice.ts
Lines 104 to 106 in 5f2510f
it would:
<App />to re-render (parent component)<Routes />to re-render as a child<OnboardingFlow />which doesn't have/password_resetLiteFarm/packages/webapp/src/routes/index.jsx
Lines 343 to 344 in 5f2510f
LiteFarm/packages/webapp/src/routes/Onboarding.jsx
Lines 198 to 200 in 5f2510f
Solution
Made the offline activity logger's Redux subscription more granular by changing selector:
Use
currentFarmIdSelectorinstead ofuserFarmSelectorfarm_idchanges, not all userFarm stateI found this bug while testing the React Router upgrade and wanted to ship a fix as soon as possible.
Jira link: https://lite-farm.atlassian.net/browse/LF-5219
Type of change
How Has This Been Tested?
Checklist:
pnpm i18nto help with this)