Skip to content

Fix wysiwyg component binding for better consistency#65

Merged
csebianlander merged 1 commit intomainfrom
wysiwyg-fixes
Jul 15, 2025
Merged

Fix wysiwyg component binding for better consistency#65
csebianlander merged 1 commit intomainfrom
wysiwyg-fixes

Conversation

@wrose504
Copy link
Collaborator

@wrose504 wrose504 commented Jul 12, 2025

We initially made the WYSIWYG Livewire component using events to notify parent component of updated content.

While this appears to mostly work, updates appear to get missed here and there, leading to broken posts and comments. It's possible this is because the sequencing of events with respect to other component updates is not occurring as we expect. We also send events on every WYSIWYG change currently, leading to a lot of network traffic.

Livewire offers another mechanism for linking parent values to child component properties via wire:model. This PR switches posting and commenting to use modelable properties, and to decrease the number of network calls by making most calls to $wire.set disable live updates.

@wrose504 wrose504 self-assigned this Jul 12, 2025
'more_inside' => $this->purifierService->clean($dto->more_inside),
'user_id' => $dto->user_id,
'subsite_id' => $dto->subsite_id,
'state' => $dto->state,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I agree with not saving state in PostService. Looking at spots in the codebase where PostService stores a post from a PostDto, state is getting set to variously draft or to published in the dto and this would kind of thwart that setting.
I wonder if you got rid of state here because posts don't currently get published and this solves the problem? I noticed that in local and in current staging but thought the problem could be solved by adding state as a fillable property to app/Models/Post.php

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! I took this out here because it was crashing to try to set this after some earlier changes in #62 that made state unfillable in the Post model and just applied a default setting of draft for that column.

The reason for the change in #62 was that the draft/published state is actually managed differently via the laravel-drafts trait, which uses the is_current and is_published flags to manage draft state, rather than using the state column, so the state column was never changing from draft even when a post was published. I should probably remove it from the PostDto too!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK! Thank you for the background info, that's fine then!

@Anna-M-Thomas
Copy link
Collaborator

@wrose504 Hi, I had a go at reviewing this pull request!
Other than the one comment, everything else looks good to me as far as I can tell. I reviewed the documentation you linked (thank you) and confirmed that the # of network calls for WYSIWYG edits is reduced with this change, confirmed that both posts and comments save OK.

@csebianlander csebianlander merged commit 7f70134 into main Jul 15, 2025
1 check passed
@wrose504 wrose504 deleted the wysiwyg-fixes branch July 15, 2025 18:38
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.

3 participants