fix(modal): use checkbox ids for Livewire bindings (#11335)

This commit is contained in:
Andras Bacsai 2026-08-17 23:34:56 +02:00 committed by GitHub
parent 3d025a2a9b
commit 69dbfe0079
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -236,7 +236,6 @@ class="flex size-7 shrink-0 items-center justify-center rounded-md text-neutral-
@foreach ($checkboxes as $index => $checkbox) @foreach ($checkboxes as $index => $checkbox)
<div class="flex justify-between items-center mb-2"> <div class="flex justify-between items-center mb-2">
<x-forms.checkbox fullWidth :label="$checkbox['label']" :id="$checkbox['id']" <x-forms.checkbox fullWidth :label="$checkbox['label']" :id="$checkbox['id']"
:wire:model="$checkbox['id']"
x-on:change="toggleAction('{{ $checkbox['id'] }}')" :checked="$this->{$checkbox['id']}" x-on:change="toggleAction('{{ $checkbox['id'] }}')" :checked="$this->{$checkbox['id']}"
x-bind:checked="selectedActions.includes('{{ $checkbox['id'] }}')" /> x-bind:checked="selectedActions.includes('{{ $checkbox['id'] }}')" />
</div> </div>

View file

@ -1,5 +1,7 @@
<?php <?php
use Illuminate\Support\Facades\Blade;
/** /**
* Step 1 (checkbox options) should only show Continue dismiss is the header X. * Step 1 (checkbox options) should only show Continue dismiss is the header X.
*/ */
@ -13,3 +15,17 @@
->toContain('step1ButtonText') ->toContain('step1ButtonText')
->not->toContain('Cancel'); ->not->toContain('Cancel');
}); });
test('modal confirmation lets checkbox ids define their Livewire model binding', function () {
$checkbox = Blade::render(<<<'BLADE'
<x-forms.checkbox id="deleteVolumes"
x-on:change="toggleAction('deleteVolumes')"
x-bind:checked="selectedActions.includes('deleteVolumes')" />
BLADE);
expect($checkbox)
->toContain('x-on:change="toggleAction(\'deleteVolumes\')"')
->toContain('x-bind:checked="selectedActions.includes(\'deleteVolumes\')"')
->toContain('wire:model=deleteVolumes')
->toMatch('/id="deleteVolumes-[a-zA-Z0-9]{24}"/');
});