fix: prevent environment form from resetting while editing#4626
Open
veksen wants to merge 1 commit into
Open
Conversation
The application environment editor shares the application.one query with its parent page, which polls every 5s. Each refetch pushed fresh data into a useEffect that called form.reset(), wiping any in-progress edits (e.g. while scrolling down to the Save button). Gate the reset on the form not being dirty so background refetches no longer clobber unsaved edits, and reset the dirty baseline after a successful save so the form re-syncs with the server normally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR about?
While editing a service's Environment Settings, in-progress changes could be silently wiped before you got to save them — e.g. you start typing, scroll down to the Save button, and the textarea resets to the previous value.
The root cause: the application details page polls the
application.onequery every 5s (refetchInterval: 5000).ShowEnvironmentshares that same query (react-query dedupes by key), so every poll delivered freshdatainto auseEffectthat unconditionally calledform.reset(...), discarding any unsaved edits.The fix gates the reset on the form not being dirty, so a background refetch only re-syncs the form when the user has no unsaved edits. After a successful save, the dirty baseline is reset so the form continues to sync with the server normally.
Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
N/A
Screenshots (if applicable)
N/A