-
Notifications
You must be signed in to change notification settings - Fork 4
Change dirty property to track field value changes from initial state #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: stage
Are you sure you want to change the base?
Conversation
Co-authored-by: jpaladin <12514334+jpaladin@users.noreply.github.com>
Co-authored-by: jpaladin <12514334+jpaladin@users.noreply.github.com>
Co-authored-by: jpaladin <12514334+jpaladin@users.noreply.github.com>
|
@copilot there's already a state variable "dirty" inside the hook why not use it instead of adding new "isDirty" |
The existing
For example, if you load data from API using |
Thats exactly what this comment references Remove isDirty and use existing dirty |
The existing The requirement is to track "has value changed from initial" persistently across blur events. The existing We need both:
|
The new expected behaviour is that we only consider the input dirty if the value is changed in regards to default value. |
Co-authored-by: jpaladin <12514334+jpaladin@users.noreply.github.com>
... Changed |
Enables tracking whether form field values have changed from their initial values, commonly needed to conditionally enable Save buttons.
Changes
Field-level tracking
dirtyfrom state variable to computed propertyvalueagainstresetToValue:dirty = value !== resetToValuefalsewhen reverted to initialForm-level helper
isDirty(fields)utility function usesfield.dirtypropertytrueif any field has changed from initial valueData loading support
setValue()andsetValues()update both value and initial valuedirtyfalse after programmatic updates (e.g., loading from API)Usage
Implementation Notes
dirtynow tracks value changes from initial state (for both validation and save button logic)No longer a temporary flag - behaves as persistent computed property
TypeScript definitions and tests updated accordingly
Fixes [Proposition]
isDirtyorisChangedproperty #105Original prompt
isDirtyorisChangedproperty #105💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.