From 1ddec358a55793bd12a2d4f99d6b866c756dbb37 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 2 Aug 2025 15:45:21 +0200 Subject: [PATCH] feat(input): add autofocus attribute to input component for improved accessibility --- app/View/Components/Forms/Input.php | 1 + resources/views/components/forms/input.blade.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/View/Components/Forms/Input.php b/app/View/Components/Forms/Input.php index 7283ef20f..a7bd87949 100644 --- a/app/View/Components/Forms/Input.php +++ b/app/View/Components/Forms/Input.php @@ -25,6 +25,7 @@ class Input extends Component public string $autocomplete = 'off', public ?int $minlength = null, public ?int $maxlength = null, + public bool $autofocus = false, ) {} public function render(): View|Closure|string diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php index 20e6485bf..799a5f110 100644 --- a/resources/views/components/forms/input.blade.php +++ b/resources/views/components/forms/input.blade.php @@ -32,7 +32,7 @@ wire:dirty.class="dark:focus:ring-warning dark:ring-warning" wire:loading.attr="disabled" type="{{ $type }}" @readonly($readonly) @disabled($disabled) id="{{ $id }}" name="{{ $name }}" placeholder="{{ $attributes->get('placeholder') }}" - aria-placeholder="{{ $attributes->get('placeholder') }}"> + aria-placeholder="{{ $attributes->get('placeholder') }}" @if ($autofocus) x-ref="autofocusInput" @endif> @else @@ -45,7 +45,7 @@ max="{{ $attributes->get('max') }}" minlength="{{ $attributes->get('minlength') }}" maxlength="{{ $attributes->get('maxlength') }}" @if ($id !== 'null') id={{ $id }} @endif name="{{ $name }}" - placeholder="{{ $attributes->get('placeholder') }}"> + placeholder="{{ $attributes->get('placeholder') }}" @if ($autofocus) x-ref="autofocusInput" @endif> @endif @if (!$label && $helper)