Keep a deferred wire:model on the tabs deferred
Plan step 36, navigation review. The tabs rewrite appended `.live` to @entangle, so every tab set bound with a plain wire:model sent a request on each click. @entangle already adds `.live` for wire:model.live, which the view's own header promises is the caller's choice. Pinned for both spellings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
co-authored by
Claude Opus 5
parent
c3225d5353
commit
348803484a
@@ -42,7 +42,7 @@
|
||||
|
||||
<div
|
||||
x-data="{
|
||||
@if ($model !== null) selected: @entangle($attributes->wire('model')).live, @else selected: @js($initial), @endif
|
||||
@if ($model !== null) selected: @entangle($attributes->wire('model')), @else selected: @js($initial), @endif
|
||||
tabsId: @js($id),
|
||||
...materialTabs(),
|
||||
}"
|
||||
|
||||
@@ -74,6 +74,36 @@ it('entangles the chosen tab with Livewire and renders the one the property name
|
||||
->toMatch('/id="[^"]+-people-panel"(?![^>]*style="display: none")/');
|
||||
});
|
||||
|
||||
it('tells the server at once only when the caller asked with wire:model.live', function () {
|
||||
Livewire::component('tabs-deferred-probe', new class extends Component
|
||||
{
|
||||
public string $tab = 'files';
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
return '<div><x-tabs wire:model="tab" :tabs="[[\'name\' => \'files\', \'label\' => \'Files\'], [\'name\' => \'people\', \'label\' => \'People\']]" /></div>';
|
||||
}
|
||||
});
|
||||
|
||||
Livewire::component('tabs-live-probe', new class extends Component
|
||||
{
|
||||
public string $tab = 'files';
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
return '<div><x-tabs wire:model.live="tab" :tabs="[[\'name\' => \'files\', \'label\' => \'Files\'], [\'name\' => \'people\', \'label\' => \'People\']]" /></div>';
|
||||
}
|
||||
});
|
||||
|
||||
// @entangle appends `.live` itself for `wire:model.live`; the view adds nothing of its own, so a
|
||||
// deferred `wire:model` stays deferred.
|
||||
$live = Livewire::test('tabs-live-probe')->html();
|
||||
|
||||
expect(Livewire::test('tabs-deferred-probe')->html())->toContain(".entangle('tab')")->not->toContain(".entangle('tab').live")
|
||||
->and(substr_count($live, ".entangle('tab').live"))->toBe(1)
|
||||
->and($live)->not->toContain('.live.live');
|
||||
});
|
||||
|
||||
it('keeps the tab bar on M3\'s offsets, indicator inset and focus ring', function () {
|
||||
$css = ComponentStylesheet::read('tabs');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user