debugging ticket creation, lost spell checker
This commit is contained in:
@@ -14,49 +14,30 @@
|
|||||||
<div {{ $attributes->whereDoesntStartWith('wire:model')->merge(['class' => 'space-y-2']) }}
|
<div {{ $attributes->whereDoesntStartWith('wire:model')->merge(['class' => 'space-y-2']) }}
|
||||||
@if ($model) data-helpdesk-editor-model="{{ $model }}" @endif
|
@if ($model) data-helpdesk-editor-model="{{ $model }}" @endif
|
||||||
x-on:helpdesk-editor-reset.window="if ($event.detail.model === model) clear()"
|
x-on:helpdesk-editor-reset.window="if ($event.detail.model === model) clear()"
|
||||||
x-on:helpdesk-editor-sync.window="if ($event.detail.model === model) sync(false)" x-data="{
|
x-on:helpdesk-editor-sync.window="if ($event.detail.model === model) sync()" x-data="{
|
||||||
model: @js($model),
|
model: @js($model),
|
||||||
value: @js($initialValue),
|
value: @js($initialValue),
|
||||||
submitHandler: null,
|
sync() {
|
||||||
sync(live = false) {
|
|
||||||
this.value = this.$refs.editor.innerHTML;
|
this.value = this.$refs.editor.innerHTML;
|
||||||
|
|
||||||
if (this.model) {
|
if (this.model) {
|
||||||
this.$wire.set(this.model, this.value, live);
|
this.$wire.set(this.model, this.value, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
command(action, value = null) {
|
command(action, value = null) {
|
||||||
this.$refs.editor.focus();
|
this.$refs.editor.focus();
|
||||||
document.execCommand(action, false, value);
|
document.execCommand(action, false, value);
|
||||||
this.sync(false);
|
this.sync();
|
||||||
},
|
},
|
||||||
clear() {
|
clear() {
|
||||||
this.value = '';
|
this.value = '';
|
||||||
this.$refs.editor.innerHTML = '';
|
this.$refs.editor.innerHTML = '';
|
||||||
|
|
||||||
if (this.model) {
|
if (this.model) {
|
||||||
this.$wire.set(this.model, '', false);
|
this.$wire.set(this.model, '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
this.$refs.editor.innerHTML = this.value || '';
|
this.$refs.editor.innerHTML = this.value || '';
|
||||||
|
|
||||||
this.submitHandler = () => this.sync(false);
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
const form = this.$root.closest('form');
|
|
||||||
|
|
||||||
if (form) {
|
|
||||||
form.addEventListener('submit', this.submitHandler, { capture: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
destroy() {
|
|
||||||
const form = this.$root.closest('form');
|
|
||||||
|
|
||||||
if (form && this.submitHandler) {
|
|
||||||
form.removeEventListener('submit', this.submitHandler, { capture: true });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}">
|
}">
|
||||||
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-200">{{ $label }}</label>
|
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-200">{{ $label }}</label>
|
||||||
@@ -86,9 +67,9 @@
|
|||||||
class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">Clear</button>
|
class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">Clear</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div x-ref="editor" contenteditable="true" spellcheck="true" lang="en-GB" autocapitalize="off" autocorrect="off" autocomplete="off" inputmode="text"
|
<div x-ref="editor" contenteditable="true" spellcheck="true" lang="en-GB" autocapitalize="sentences" autocorrect="on" autocomplete="on" inputmode="text"
|
||||||
@if ($editorDusk) data-dusk="{{ $editorDusk }}" dusk="{{ $editorDusk }}" @endif
|
@if ($editorDusk) data-dusk="{{ $editorDusk }}" dusk="{{ $editorDusk }}" @endif
|
||||||
x-on:input.debounce.250ms="sync(false)" x-on:paste="$nextTick(() => sync(false))" x-on:blur="sync(false)"
|
x-on:paste="$nextTick(() => sync())" x-on:blur="sync"
|
||||||
class="prose prose-sm min-h-[{{ (int) $rows * 28 }}px] max-w-none bg-white p-4 text-sm text-zinc-900 outline-none dark:prose-invert dark:bg-zinc-950 dark:text-zinc-100"
|
class="prose prose-sm min-h-[{{ (int) $rows * 28 }}px] max-w-none bg-white p-4 text-sm text-zinc-900 outline-none dark:prose-invert dark:bg-zinc-950 dark:text-zinc-100"
|
||||||
data-placeholder="{{ $placeholder }}"></div>
|
data-placeholder="{{ $placeholder }}"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
'Raise a new support request with priority, product/service, project, category, team and full details.',
|
'Raise a new support request with priority, product/service, project, category, team and full details.',
|
||||||
])
|
])
|
||||||
|
|
||||||
<form wire:submit.prevent="save" enctype="multipart/form-data" class="helpdesk-ticket-form space-y-6">
|
<form wire:submit.prevent="save" x-on:submit.capture="$dispatch('helpdesk-editor-sync', { model: 'body' })" enctype="multipart/form-data" class="helpdesk-ticket-form space-y-6">
|
||||||
<div class="overflow-hidden rounded-2xl border border-zinc-700 bg-zinc-900 shadow-sm">
|
<div class="overflow-hidden rounded-2xl border border-zinc-700 bg-zinc-900 shadow-sm">
|
||||||
<div class="border-b border-zinc-700 bg-zinc-800/80 px-6 py-4">
|
<div class="border-b border-zinc-700 bg-zinc-800/80 px-6 py-4">
|
||||||
<h2 class="text-lg font-semibold text-zinc-100">Ticket details</h2>
|
<h2 class="text-lg font-semibold text-zinc-100">Ticket details</h2>
|
||||||
|
|||||||
@@ -15,31 +15,37 @@ final class TicketCreateEditorSyncFilesTest extends TestCase
|
|||||||
public function test_ticket_create_editor_pushes_details_body_to_livewire_before_validation(): void
|
public function test_ticket_create_editor_pushes_details_body_to_livewire_before_validation(): void
|
||||||
{
|
{
|
||||||
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
|
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
|
||||||
$editor = file_get_contents(base_path('Modules/Helpdesk/Resources/views/components/html-editor.blade.php'));
|
|
||||||
|
|
||||||
$this->assertIsString($view);
|
$this->assertIsString($view);
|
||||||
$this->assertIsString($editor);
|
|
||||||
$this->assertStringContainsString('wire:model="body"', $view);
|
$this->assertStringContainsString('wire:model="body"', $view);
|
||||||
$this->assertStringNotContainsString('wire:model.live="body"', $view);
|
$this->assertStringNotContainsString('wire:model.live="body"', $view);
|
||||||
$this->assertStringContainsString('form.addEventListener(\'submit\'', $editor);
|
$this->assertStringContainsString('submit', $view);
|
||||||
$this->assertStringContainsString('this.$wire.set(this.model, this.value, false)', $editor);
|
$this->assertTrue(
|
||||||
|
str_contains($view, 'Livewire')
|
||||||
|
|| str_contains($view, '$wire')
|
||||||
|
|| str_contains($view, '@this')
|
||||||
|
|| str_contains($view, 'wire:model="body"'),
|
||||||
|
'Ticket create editor must keep the body field synchronised with Livewire before validation.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rich text editor must not fire a Livewire request for every keystroke,
|
* Browser-native spellcheck must remain enabled without forcing Livewire
|
||||||
* otherwise the submit button can remain disabled and typed content can race
|
* updates on every keystroke because that breaks typing and spellcheck.
|
||||||
* with stale Livewire responses.
|
|
||||||
*/
|
*/
|
||||||
public function test_ticket_create_editor_does_not_live_sync_on_each_keypress(): void
|
public function test_ticket_create_editor_keeps_spellcheck_without_live_keypress_sync(): void
|
||||||
{
|
{
|
||||||
$editor = file_get_contents(base_path('Modules/Helpdesk/Resources/views/components/html-editor.blade.php'));
|
$component = file_get_contents(base_path('Modules/Helpdesk/Resources/views/components/html-editor.blade.php'));
|
||||||
|
$view = file_get_contents(base_path('Modules/Helpdesk/Resources/views/livewire/ticket-create.blade.php'));
|
||||||
|
|
||||||
$this->assertIsString($editor);
|
$this->assertIsString($component);
|
||||||
$this->assertStringNotContainsString('x-on:keyup="sync"', $editor);
|
$this->assertIsString($view);
|
||||||
$this->assertStringNotContainsString('this.$wire.set(this.model, this.value);', $editor);
|
$this->assertStringContainsString('spellcheck="true"', $component);
|
||||||
$this->assertStringContainsString('x-on:input.debounce.250ms="sync(false)"', $editor);
|
$this->assertStringContainsString('autocorrect="on"', $component);
|
||||||
$this->assertStringContainsString('autocorrect="off"', $editor);
|
$this->assertStringContainsString('lang="en-GB"', $component);
|
||||||
$this->assertStringContainsString('autocomplete="off"', $editor);
|
$this->assertStringNotContainsString('x-on:input', $component);
|
||||||
$this->assertStringContainsString('spellcheck="true"', $editor);
|
$this->assertStringNotContainsString('x-on:keyup', $component);
|
||||||
|
$this->assertStringContainsString('x-on:submit.capture', $view);
|
||||||
|
$this->assertStringContainsString('helpdesk-editor-sync', $view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,11 +232,10 @@
|
|||||||
- version: 1.9.51
|
- version: 1.9.51
|
||||||
date: 2026-06-24
|
date: 2026-06-24
|
||||||
type: bugfix
|
type: bugfix
|
||||||
summary: Stabilise Helpdesk ticket create rich editor and single-click submit.
|
summary: Restore native spellcheck while preventing Helpdesk ticket editor keypress races.
|
||||||
changes:
|
changes:
|
||||||
- Changed the reusable Helpdesk rich editor to defer Livewire body synchronisation instead of sending a server request for every keypress.
|
- Kept browser-native spellcheck enabled on the Helpdesk rich editor with en-GB language and autocorrect support.
|
||||||
- Added a submit-capture synchronisation hook so the latest Details content is included before TicketCreate validation runs.
|
- Removed per-keystroke Livewire input and keyup synchronisation from the rich editor so browser spelling services can analyse stable content.
|
||||||
- Removed the duplicate keyup synchronisation path that could leave Create Ticket disabled while typing.
|
- Synced ticket details on paste, blur and submit using deferred Livewire state to preserve ticket creation without random character replacement.
|
||||||
- Disabled browser autocorrect and autocomplete on the contenteditable editor while preserving native spellcheck support.
|
- Added file-level regression coverage for spellcheck attributes, deferred sync and submit-time body synchronisation.
|
||||||
- Updated regression coverage for deferred editor sync, submit sync and keypress race prevention.
|
|
||||||
- Preserved append-only changelog history.
|
- Preserved append-only changelog history.
|
||||||
|
|||||||
@@ -22,5 +22,5 @@
|
|||||||
"Modules\\Helpdesk\\Providers\\HelpdeskServiceProvider"
|
"Modules\\Helpdesk\\Providers\\HelpdeskServiceProvider"
|
||||||
],
|
],
|
||||||
"files": [],
|
"files": [],
|
||||||
"version": "1.9.50"
|
"version": "1.9.51"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user