Merge pull request #1971 from w3cj/allow-tab-in-textarea

feat: allow tab in textarea
This commit is contained in:
Andras Bacsai
2024-04-12 14:14:57 +02:00
committed by GitHub
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 }}