Save on enter and debounce numeric input

This commit is contained in:
TinaH
2023-02-24 13:03:48 +01:00
committed by GitHub
parent 2e7150d72f
commit bf25d906b0
@@ -13,6 +13,13 @@
error: undefined,
state: @js($state),
isLoading: false,
update: async function(value) {
this.isLoading = true
this.response = await $wire.updateTableColumnState(@js($getName()), @js($recordKey), value)
this.error = response?.error ?? undefined
if (! this.error) this.state = response
this.isLoading = false
}
}"
x-init="
Livewire.hook('message.processed', (component) => {
@@ -46,13 +53,8 @@
{!! ($inputMode = $getInputMode()) ? "inputmode=\"{$inputMode}\"" : null !!}
{!! ($placeholder = $getPlaceholder()) ? "placeholder=\"{$placeholder}\"" : null !!}
{!! ($interval = $getStep()) ? "step=\"{$interval}\"" : null !!}
x-on:change="
isLoading = true
response = await $wire.updateTableColumnState(@js($getName()), @js($recordKey), $event.target.value)
error = response?.error ?? undefined
if (! error) state = response
isLoading = false
"
x-on:change{{ $getType() === 'number' ? '.debounce.750ms' : null }}="update($event.target.value)"
x-on:keydown.enter="update($event.target.value)"
:readonly="isLoading"
x-tooltip="error"
{{ $attributes->merge($getExtraInputAttributes())->merge($getExtraAttributes())->class([