Skip to content

Flux button shows loading state on all buttons when used inside @foreach loop #2470

@Rodion15

Description

@Rodion15

Title:

Flux button shows loading state on all buttons when used inside @foreach loop

Description:

When using <flux:button> with wire:click inside a @foreach loop, clicking on one button triggers the loading state on all buttons instead of only the clicked button.

However, when buttons are defined individually (not in a loop), the loading state works correctly and only appears on the clicked button.

Steps To Reproduce:

  1. Create a Livewire component with flux buttons inside a @foreach loop
  2. Add wire:click action to each button
  3. Click on any button

Code example that shows the bug:

@foreach($this->districts as $zone)
    <flux:button wire:click="selectZone({{ $zone->id }})" size="xs">Open</flux:button>
@endforeach

Expected behavior: Only the clicked button should show loading state

Actual behavior: All buttons in the loop show loading state

Working example (without foreach):

<flux:button wire:click="selectZone(1)" size="xs">Open</flux:button>
<flux:button wire:click="selectZone(2)" size="xs">Open</flux:button>
<flux:button wire:click="selectZone(3)" size="xs">Open</flux:button>

In this case, only the clicked button shows loading state (correct behavior).

Environment:

  • Laravel version: 12.53.0
  • Livewire version: 4.2.1
  • Flux version: 2.12.1

Screenshot:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions