Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TripleSevenMike's avatar

Livewire Select Dropdown Reverts to Old Value After Update – View Not Updating Properly

Hi everyone, I'm working on a Livewire component where I manage guest seat assignments for an event.

The setup:

  • I have a list of guests and a list of seats.
  • Each seat can have one guest assigned (guest_id).
  • Guests that are already assigned to a seat should no longer be available as options in the dropdown.
  • I'm displaying each seat as a select dropdown. The available options in each select are only the guests who don't yet have a seat assigned.
  • When I select a guest from the dropdown, the change should be saved to the database immediately via wire:change.

The problem: When I select a different guest for a seat:

  • The new selection briefly appears in the dropdown.
  • But then it immediately reverts back to the previous value (even though the correct value is saved in the database).
  • After a full page reload, the correct updated value appears as expected.
  • It seems like the seatGuestMap is updated correctly, and the database reflects the change, but the view is not re-rendering correctly right away.

I've tried a few different approaches to handle this, including tweaking how data is refreshed and how models are bound, but I keep running into the same issue.

Here is the relevant code:

And blade file:

<div class="space-y-6">
    <ol>
        @foreach($seats as $seat)
            <div wire:key="seat-{{ $seat->id }}" class="p-2 border border-gray-300 mb-2">
                <p>Seat {{ $seat->seat_number }}</p>

                <select wire:model.lazy="seatGuestMap.{{ $seat->id }}" wire:change="updateSeatGuest({{ $seat->id }})">
                    <option value="">-- Select guest --</option>
                    <option value="{{ $seat->guest_id }}" selected>
                        {{ $seat->guest->name ?? 'null' }}
                    </option>
                    @foreach($guests as $guest)
                        <option value="{{ $guest->id }}">
                            {{ $guest->name ?? 'Guest #' . $guest->id }}
                        </option>
                    @endforeach
                </select>
            </div>
        @endforeach
    </ol>
</div>
0 likes
4 replies
Snapey's avatar

not using wire:key in foreach loops WILL ALWAYS cause Dom Diff errors.

TripleSevenMike's avatar

Good point, I forgot about the key in the option tags.

After adding it, the behavior of the component changed slightly. Previously, after selecting a new option in select, the new one would appear and then jump to the old one. Now the new one appears for a moment and then jumps to the default option " -- Select guest --".

I see that the problem occurs when I update the array ($guests) from which I create available options in selects.

Snapey's avatar

@TripleSevenMike I suspect the wire:change is playing a part in this.

Also, you should only include this

                    <option value="{{ $seat->guest_id }}" selected>
                        {{ $seat->guest->name ?? 'null' }}
                    </option>

if the guest has actually been selected?

You may get more insight by installing Laravel Debugbar as it includes a Livewire tab and allows you to inspect the state of a component at any time.

Please or to participate in this conversation.