Skip to content

Improve dirty state handling - #2044

Open
labkey-nicka wants to merge 6 commits into
developfrom
fb_improve_dirty
Open

Improve dirty state handling#2044
labkey-nicka wants to merge 6 commits into
developfrom
fb_improve_dirty

Conversation

@labkey-nicka

@labkey-nicka labkey-nicka commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Rationale

This improves our dirty state handling to catch a couple of cases we are missing:

  1. Changes to a SelectInput in a Formsy form are not being recorded as a dirty state change.
  2. Nested components that make use of useRouteLeave override beforeunload handling allowing the user to navigate away from dirty page (e.g., from a modal) and not receive an alert.

Related Pull Requests

Changes

In useRouteLeave:

  • Each consumer now owns its dirty bit; setIsDirty and unmount only affect that bit
  • usePrompt and beforeunload now block on the aggregate, so React Router's single-blocker limit no longer masks consumers
  • New consumers inherit the dirty state at mount, and one ref-counted beforeunload listener replaces one per consumer

In Formsy:

  • isChanged() now uses each input's mount-time pristineValue, not the live value prop a controlled parent overwrites
  • resetModel() applies explicit values via resetValue(), making them the new baseline so a reset isn't reported dirty
  • withFormsy skips re-applying a value the input already holds, dropping a redundant validation and duplicate onChange

@labkey-nicka labkey-nicka self-assigned this Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant