Skip to content

fix: File attachments saving Livewire temporary URLs instead of permanent storage URLs.#125

Open
robinmalburn wants to merge 3 commits into
amidesfahani:4.xfrom
robinmalburn:fix/imageSavePath
Open

fix: File attachments saving Livewire temporary URLs instead of permanent storage URLs.#125
robinmalburn wants to merge 3 commits into
amidesfahani:4.xfrom
robinmalburn:fix/imageSavePath

Conversation

@robinmalburn

@robinmalburn robinmalburn commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

This PR addresses two related bugs affecting file attachment handling when saving TinyEditor content.

  1. 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.

  2. 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 $fileAttachmentIds array 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.

  3. 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 SetContent events, but also sets success before setting up the event handler. Calling success before 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. Switched NodeChange instead of SetContent since NodeChange fires after the DOM is actually mutated, which is what paste triggers rather than SetContent

Related Issues

#111 - Can't upload image with custom fileAttachmentProvider
#113 - Images in existing blocks saved as Livewire preview URLs
#108 - Image Pasting Upload Issue

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant