Skip to content

LF-5169: Previously Applied Filters Persist on Animals Page After Switching Farms#4080

Open
litefarm-pr-bot wants to merge 1 commit intointegrationfrom
LF-5169-previously-applied-filters-persist-on-animals-page-after-switching-farms
Open

LF-5169: Previously Applied Filters Persist on Animals Page After Switching Farms#4080
litefarm-pr-bot wants to merge 1 commit intointegrationfrom
LF-5169-previously-applied-filters-persist-on-animals-page-after-switching-farms

Conversation

@litefarm-pr-bot
Copy link
Collaborator

Description

When a user applies filters on the Animals page and then switches to a different farm, the filter state was stored in tempStateReducer.filterReducer (Redux). The root reducer only clears farmStateReducer on farm switch, and clearOldFarmStateSaga — which handles cleanup during the farm-switch saga flow — did not include a reset for the Animals filter. Because the filter state lives outside farmStateReducer, it survived the farm transition intact.

The fix adds resetAnimalsFilter() to clearOldFarmStateSaga in containers/saga.js, alongside the existing resetTasks() and resetDateRange() calls. This ensures Animal filters are cleared at the same point in the farm-switch flow as other domain-specific state.

Any new domain-specific filter state stored in tempStateReducer should similarly be reset in clearOldFarmStateSaga rather than relying on the root reducer's SWITCH_FARMS handling, which only covers farmStateReducer.

Jira link: https://lite-farm.atlassian.net/browse/LF-5169

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Logic change reviewed in source code. No local frontend running; visual review not performed. The fix is a single yield put(resetAnimalsFilter()) call in an existing saga, consistent with how resetTasks() is handled in the same function.

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have ordered translation keys alphabetically (optional: run pnpm i18n to help with this)
  • I have added the GNU General Public License to all new files

@litefarm-pr-bot litefarm-pr-bot requested review from a team as code owners March 9, 2026 15:56
@litefarm-pr-bot litefarm-pr-bot requested review from SayakaOno and removed request for a team March 9, 2026 15:56
@kathyavini kathyavini added the bug Something isn't working label Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants