diff --git a/resources/views/components/modal.blade.php b/resources/views/components/modal.blade.php index ffb01c44..f77b271d 100644 --- a/resources/views/components/modal.blade.php +++ b/resources/views/components/modal.blade.php @@ -78,18 +78,19 @@ @endif
$fullscreen])> - @if (filled($title) || $icon) -
$fullscreen && ! $icon, 'text-center' => $icon])> + @if (filled($title) || filled($subtitle) || $icon) + {{-- A full-screen dialog's bar names it on a phone, so only the subtitle stays there. --}} +
$fullscreen && ! $icon && blank($subtitle), 'text-center' => $icon])> @if ($icon) @endif @if (filled($title)) -

{{ $title }}

+

$fullscreen && ! $icon])>{{ $title }}

@endif @if (filled($subtitle)) -

{{ $subtitle }}

+

filled($title) || $icon, 'max-sm:mt-0' => $fullscreen && ! $icon])>{{ $subtitle }}

@endif @if ($separator) diff --git a/tests/Feature/Components/OverlayTest.php b/tests/Feature/Components/OverlayTest.php index 124f610f..1539a211 100644 --- a/tests/Feature/Components/OverlayTest.php +++ b/tests/Feature/Components/OverlayTest.php @@ -44,6 +44,17 @@ it('uses the surrounding Alpine scope without wire:model, and stays open when pe ->toContain('aria-label="Close"'); }); +it('keeps a full-screen dialog\'s subtitle on a phone, where its bar carries the title', function () { + $html = (string) $this->blade('Text'); + + expect($html) + ->toMatch('/

/') + ->toContain('

Scan the code

') + ->not->toContain('
') + ->and((string) $this->blade('Text'))->toContain('
') + ->and((string) $this->blade('Text'))->toContain('

Only a subtitle

'); +}); + it('slides a side sheet in from either edge, and is a pane from xl when asked', function () { expect((string) $this->blade('Body')) ->toContain('x-trap.inert.noscroll="open && ! wide"')