Enhance settings form with unsaved changes tracking.#1167
Open
yoav-cloud wants to merge 1 commit intocloudinary:masterfrom
Open
Enhance settings form with unsaved changes tracking.#1167yoav-cloud wants to merge 1 commit intocloudinary:masterfrom
yoav-cloud wants to merge 1 commit intocloudinary:masterfrom
Conversation
Added CSS styles for unsaved changes indication and modified form attributes for better tracking. Improved JavaScript functionality for form state management.
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.
Adds client-side tracking of whether the Cloudinary settings form differs from the state that was loaded with the page. If the user has edited trackable fields and tries to leave without saving, they get a clear warning instead of losing work silently.
cld-wp-plugin-unsaved-check.mov
What changed
Behavior
Dirty detection — On input/change, the form serializes values for relevant fields (inputs, selects, textareas; skips hidden WordPress fields, nonces, and non-data controls) and compares against the initial snapshot.
beforeunload — Browsers show their standard “leave site?” prompt when there are unsaved changes and the user closes the tab or navigates away in ways that fire beforeunload.
In-app links — Clicks on normal same-window links show a confirm() with the same message so navigation inside the admin is guarded too. Modifier-key opens, target="_blank", download, javascript:, and hash-only links are left alone so common workflows are not blocked.
Save / submit — Submitting the form clears the dirty state so the user is not warned after a deliberate save.
Save button affordance — While dirty, real save controls get a trailing * and a cld-settings-submit-dirty class (styled with a visible outline). Only button[name="cld_submission"] (with a fallback to #submit / input[type="submit"]) is updated so other primary actions on the same form (for example disconnect) are not mislabeled.
Markup and styling
SCSS adds styling for .cld-settings-submit-dirty; built css/cloudinary.css / js/cloudinary.js are updated.
Copy
User-facing string is passed through wp.i18n.__ when available: “You have unsaved changes. If you leave this page, your changes will be lost.”