fix: File attachments saving Livewire temporary URLs instead of permanent storage URLs.#125
Open
robinmalburn wants to merge 3 commits into
Open
fix: File attachments saving Livewire temporary URLs instead of permanent storage URLs.#125robinmalburn wants to merge 3 commits into
robinmalburn wants to merge 3 commits into
Conversation
…nent storage URLs.
…ange event to ensure pasted images are properly handled.
pitchayakit
added a commit
to pitchayakit/filament-tinyeditor
that referenced
this pull request
Jun 30, 2026
…midesfahani#125) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
This PR addresses two related bugs affecting file attachment handling when saving TinyEditor content.
Incorrect lifecycle hook for file processing
The file attachment processing logic (parsing editor HTML, moving temporary files to permanent storage, and rewriting image URLs) was registered via beforeStateDehydrated. This hook fires when Livewire serialises component state to send to the browser, not when the form is submitted and the model is being saved. As a result, the processing logic was never executing at the correct point in the lifecycle, leaving temporary Livewire preview URLs embedded in the saved content rather than the permanent storage URLs. This fix moves this logic into dehydrateStateUsing, which fires when Filament prepares field state for saving to the model.
Incorrect file ID used during cleanup
After successfully saving an uploaded file attachment, the original code was adding
$fileKey(the temporary Livewire upload identifier) to the$fileAttachmentIdsarray used to determine which files to preserve during cleanup. It should be adding$nodeAttrsId(the permanent storage identifier returned after saving). This meant the cleanup process could incorrectly target a file that had just been successfully saved.Pasted images not correctly processed
Pasted images aren't detected by the current upload handling. There are two issues here: the current handling relies on listening for
SetContentevents, but also sets success before setting up the event handler. Callingsuccessbefore setting up the event handler means that for paste actions, the action has already been processed before the handler is ever set up, so the event never fires. SwitchedNodeChangeinstead ofSetContentsinceNodeChangefires after the DOM is actually mutated, which is what paste triggers rather thanSetContentRelated Issues
#111 - Can't upload image with custom fileAttachmentProvider
#113 - Images in existing blocks saved as Livewire preview URLs
#108 - Image Pasting Upload Issue