Repository navigation
Conversation
Every save posts whatever $('#image')[0].files holds, and a file input
keeps its selection after the form is submitted. So once an image had
been uploaded, the next save in that same session re-sent the identical
file; the server versions the image whenever a file arrives, so the
cache-busting sequence advanced for an edit that never touched it.
Reloading the tab cleared the input, which is why the issue only
reproduced within a session.
Clear the input once a save succeeds. The server side is right as it
stands: a posted file does mean the image changed.
Clearing with val() fires no event, so the form isn't marked dirty and
the change handler doesn't swap the preview for a placeholder.
dduugg
force-pushed
the
issue-542-image-reversion
branch
from
October 9, 2026 03:39
c568e90 to
50f84e8
Compare
Contributor
|
we should hang on to this until after the table changes. that code tweaks the manage endpoint's handling of re:
this will be fixed once the table format changes. it has a separate images tables which includes a counter for image changes separate from other data changes. |
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.
Fixes #542.
Upload an image, save, then make a text-only change and save again in the same tab: the image's version is bumped even though the image never changed. Reload the tab between the two saves and it isn't.
Cause
A file input keeps its selection after the form is submitted, and every save posts whatever it holds:
So the second save re-sends the identical file. The server versions the image whenever a file arrives:
That server-side rule is correct as written — a posted file does mean the image changed. The wrong part is the client posting a file when nothing was picked. That also explains the issue's own note that a reload avoids it: reloading clears the input.
The change
Clear the input once a save succeeds:
Placed in the common tail of the
successhandler, so it covers both the new-event and existing-event branches.Two things that made
val('')the right way to do it: it fires no event, socheckForChanges()(which listens forinput) doesn't mark the form dirty and raise a spurious "Leave site?" prompt, and the#imagechange handler doesn't fire and swap the preview for a placeholder. The displayed image is already updated fromreturnVal.imagejust above.Verification
Reproduced on
mainfirst, driving the real form in the browser, then confirmed fixed. Watching both the postedFormDatakeys and the stored row:Before — image saved as
2-3.png, then a title-only save:file,json2-3.pngfile,json2-4.png← bumpedThe input still held
ride.pnggoing into the second save.After:
file,json2-5.pngjson2-5.png← heldfile,json2-7.png← bumps, as it shouldThe title did update on the text-only save, so the save itself still works; only the needless re-upload is gone. After each save the input reports 0 files, and the on-page image still renders (
naturalWidth > 0, pointing at/eventimages/2-7.png).Worth separating from the above:
calevent.changesstill increments on every save. That counter is the ical feed's change signal and is supposed to move whenever the event is edited. What this fixes is the image filename's cache-busting sequence, which should only move when the image does.Backend suite unaffected: 55 passed, 0 failed. (The change is theme JS, which has no test suite.)