feat: allow tab in textarea

This commit is contained in:
w3cj
2024-04-12 05:33:56 -06:00
parent cf01d32237
commit d46a565e6c
4 changed files with 19 additions and 3 deletions

View File

@@ -1,3 +1,18 @@
<script>
function handleKeydown(e) {
if (e.keyCode === 9) {
e.preventDefault();
e.target.setRangeText(
'\t',
e.target.selectionStart,
e.target.selectionStart,
'end'
);
}
}
</script>
<div class="flex-1 form-control">
@if ($label)
<label class="flex items-center gap-1 mb-1 text-sm font-medium">{{ $label }}
@@ -41,7 +56,7 @@
</div>
@else
<textarea placeholder="{{ $placeholder }}" {{ $attributes->merge(['class' => $defaultClass]) }}
<textarea @keydown.tab="{{ $allowTab }} && handleKeydown" placeholder="{{ $placeholder }}" {{ $attributes->merge(['class' => $defaultClass]) }}
@if ($realtimeValidation) wire:model.debounce.200ms="{{ $id }}"
@else
wire:model={{ $value ?? $id }}