Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loadable attribute for inputs #1286

Open
benjibee opened this issue Mar 10, 2025 · 4 comments · May be fixed by #1357
Open

Loadable attribute for inputs #1286

benjibee opened this issue Mar 10, 2025 · 4 comments · May be fixed by #1357

Comments

@benjibee
Copy link

The documentation has quite an elegant example of an inset loader on an input:

<flux:input icon-trailing="loading" placeholder="Search transactions" />

I might be missing something but how exactly would this be used with Livewire? I can use <flux:field> here and recreate the icon element from the input component as such:

<flux:field>
    <flux:label>Search</flux:label>

    <div class="relative">
        <flux:input wire:model.live="search" placeholder="Search transactions" />

        <div wire:loading class="pointer-events-none absolute top-2 bottom-0 flex items-center justify-center text-xs text-zinc-400/75 pr-3 right-0">
            <flux:icon icon="loading" variant="mini" />
        </div>
    </div>

    <flux:error name="search" />
</flux:field>

But this doesn't seem like a great solution. I could imagine something along the lines of copyable, viewable, etc.

<flux:input wire:model.live="search" placeholder="Search transactions" loadable />

{{-- With target specified --}}
<flux:input wire:model.live="search" placeholder="Search transactions" loadable="term" />

Originally posted by @benjibee in #332

@calebporzio
Copy link
Contributor

Good point, here's an API I could envision. What are everyone's thoughts?

<flux:input wire:model="search" /> -> no loading indicator ever
<flux:input wire:model.live="search" /> -> loading indicator when request is out
<flux:input wire:model.live="search" :loading="false" /> -> no loading indicator ever
<flux:input loading /> -> always show loading indicator
<flux:input loading="foo" /> -> show loading indicator when a request is out for the foo property (wire:loading + wire:target type deal)

@benjibee
Copy link
Author

benjibee commented Mar 13, 2025

Good point, here's an API I could envision. What are everyone's thoughts?

This looks like a good solution to me, and it would solve my use case 👍

@joshhanley
Copy link
Member

Yep I agree too! Will see if I can get it running 😁

@joshhanley joshhanley linked a pull request Mar 20, 2025 that will close this issue
@joshhanley
Copy link
Member

I've submitted a PR with this implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants