fix: prevent FPO placeholder from reappearing after image upload#918
Merged
chrischrischris merged 1 commit intomainfrom May 4, 2026
Merged
fix: prevent FPO placeholder from reappearing after image upload#918chrischrischris merged 1 commit intomainfrom
chrischrischris merged 1 commit intomainfrom
Conversation
Two bugs caused the upload icon to re-appear after a real image was shown: 1. imageDrop.js replaced the FPO node by stale cursor position. With multiple concurrent uploads or collaborative edits in flight the wrong node could be targeted, leaving the real URL in place and putting the FPO back. Fix: each upload now embeds the unique upload URL as a hash fragment in the FPO src (fpo.svg#<uploadUrl>) and the replacement handler finds the node by that content rather than position. 2. prose/index.js called wsProvider.connect() on every window focus event, even when the WebSocket was already open. Each redundant connect() triggered a fresh Y.js session on the collab DO, which could discard in-flight document state. Fix: guard the call with !wsProvider.wsconnected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
Commits
|
chrischrischris
approved these changes
May 4, 2026
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.
User scenario
A user uploads several images one after another in the DA editor. After the upload the real image briefly appears then reverts to the FPO/upload-icon placeholder (
/blocks/edit/img/fpo.svg).The same regression was reported by a second user after uploading a single image.
Root cause (two independent bugs)
1. FPO replaced by stale cursor position (
imageDrop.js)The original code stored
$from.posat the moment of upload, then used that position to replace the FPO after the upload response arrived. With multiple concurrent uploads, or with collaborative edits arriving in the meantime, the stored position no longer pointed at the right node. The replacement targeted the wrong image, leaving the old FPO in place.2. Redundant
wsProvider.connect()on every focus (prose/index.js)Every
window focusevent calledwsProvider.connect()unconditionally, even when the WebSocket was already open. Each spurious connect triggered a fresh Y.js session on the collab Durable Object, which can discard in-flight document state (see companion PR in da-collab).Fix
imageDrop.js— Each upload now embeds the unique upload URL as a hash fragment in the FPOsrcattribute (fpo.svg#<uploadUrl>). The replacement handler searches the document for the node whosesrcmatches that unique value rather than relying on a stale position. Concurrent uploads each get a distinct FPO identifier and are replaced independently.prose/index.js— The focus handler now guards the call with!wsProvider.wsconnected, so reconnection only happens when the WebSocket is actually closed.Related PRs
Tests
uploadImageFile gives FPO a unique src containing the upload URLconcurrent uploads use distinct FPO srcs so they can be replaced independentlyuploadImageFile replaces FPO with the real image URL after upload completes