Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(input): add autofocus attribute to input component for improved accessibility

Andras Bacsai1ddec358a557
diff --git a/app/View/Components/Forms/Input.php b/app/View/Components/Forms/Input.php
index 7283ef20f8..a7bd87949a 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 20e6485bfc..799a5f1101 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>
</div>
@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)
<x-helper :helper="$helper" />