class([
'inline-flex items-center',
'gap-0.5' => $connected,
diff --git a/resources/views/showcase/sections/buttons.blade.php b/resources/views/showcase/sections/buttons.blade.php
index 69bd916b..7bf4248a 100644
--- a/resources/views/showcase/sections/buttons.blade.php
+++ b/resources/views/showcase/sections/buttons.blade.php
@@ -76,6 +76,26 @@
BLADE,
+ 'A connected group that owns its selection' => <<<'BLADE'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ View: · marks: .
+ The shape follows at once; the colours come from each button's own :selected, which a Livewire render brings back.
+
+
+ BLADE,
'Square groups (hold a button down)' => <<<'BLADE'
diff --git a/tests/Feature/Components/ButtonGroupTest.php b/tests/Feature/Components/ButtonGroupTest.php
index d5eb2896..484f152f 100644
--- a/tests/Feature/Components/ButtonGroupTest.php
+++ b/tests/Feature/Components/ButtonGroupTest.php
@@ -36,6 +36,53 @@ it('squares a group, and a choice drawn as one', function () {
->toContain('data-shape="round"');
});
+it('takes over aria-pressed for a group that carries a selection', function () {
+ $html = (string) $this->blade('');
+
+ expect($html)
+ ->toContain('data-selection="single"')
+ ->toContain('data-selection-required')
+ ->toContain('multiple: false')
+ ->toContain('required: true')
+ ->toContain('value: null')
+ ->toContain('x-on:click="press($event)"')
+ // No model: the group takes the state from the buttons' own aria-pressed and goes on.
+ ->toContain('x-modelable="value"')
+ ->and((string) $this->blade(''))
+ ->toContain('multiple: true')
+ ->toContain('required: false')
+ ->toContain('value: []')
+ ->and((string) $this->blade(''))
+ ->not->toContain('data-selection')
+ ->not->toContain('press($event)');
+});
+
+it('entangles a selection group with the property it binds, and keeps wire:model off the div', function () {
+ $component = new class extends Component
+ {
+ public string $view = 'week';
+
+ public function render(): string
+ {
+ return <<<'BLADE'
+
+
+
+
+
+
+ BLADE;
+ }
+ };
+
+ $html = Livewire::test($component)->assertSet('view', 'week')->html();
+
+ expect($html)
+ ->toContain('data-selection="single"')
+ ->toMatch('/value: window\.Livewire\.find\(/')
+ ->and(substr_count($html, 'wire:model.live="view"'))->toBe(0);
+});
+
it('never wraps a group onto a second line', function () {
expect((string) $this->blade(''))
->not->toContain('flex-wrap');