Prevent Livewire from morphing logs when text is selected

Use Livewire's morph.updating hook to skip DOM morphing of the logs
container when user has text selected. This prevents the selection from
being lost when polling or manual refresh occurs.

The previous fix only prevented the JavaScript-based re-render, but
Livewire's morphing was still replacing the DOM elements entirely.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai 2025-12-15 10:53:02 +01:00
parent 5cc822c996
commit 6b9c633fe7
2 changed files with 12 additions and 0 deletions

View file

@ -147,6 +147,12 @@
}
},
init() {
// Prevent Livewire from morphing logs container when text is selected
Livewire.hook('morph.updating', ({ el, component, toEl, skip }) => {
if (el.id === 'logs' && this.hasActiveLogSelection()) {
skip();
}
});
// Re-render logs after Livewire updates
document.addEventListener('livewire:navigated', () => {
this.$nextTick(() => { this.renderTrigger++; });

View file

@ -186,6 +186,12 @@
this.$wire.getLogs(true);
this.logsLoaded = true;
}
// Prevent Livewire from morphing logs container when text is selected
Livewire.hook('morph.updating', ({ el, component, toEl, skip }) => {
if (el.id === 'logs' && this.hasActiveLogSelection()) {
skip();
}
});
// Re-render logs after Livewire updates
Livewire.hook('commit', ({ succeed }) => {
succeed(() => {