sveltejs / sveltejs/kit

Make `dirty` revert to false if original value is restored

Open
#17,072 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

The current behavior of dirty on a remote form is, as documented, "Whether the field or any nested field has been edited since the form was mounted". When you're using it to prevent navigation with a confirm dialog, if you modify a field and then turn it back to its original value, it's still considered dirty (and hence the whole form).

This causes the confirm dialog to pop up even if there are no obvious changes.

Describe the proposed solution

Make dirty take the original state of the form into account, so if a value changes back to its original, it's not considered dirty anymore.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the remote form implementation that computes the dirty state and its related tests; the issue does not name specific files or test cases. First trace how the original form state is stored and how field changes are compared. Done means restoring a field's original value no longer leaves the field or form dirty, while genuinely changed values still do.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.