Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit e0d56b6

Browse files
authored
Misc fixes (#354)
1 parent b71725e commit e0d56b6

File tree

20 files changed

+121
-18
lines changed

20 files changed

+121
-18
lines changed

.github/workflows/run-stub-tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
exclude:
2222
- laravel: 10.*
2323
php: 8.0
24+
- laravel: 9.*
25+
os: windows-latest
26+
- php: 8.1
27+
os: windows-latest
28+
- php: 8.0
29+
os: windows-latest
30+
- dependency-version: prefer-lowest
31+
os: windows-latest
2432

2533
name: Test Stubs ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2634

app/app/Http/Controllers/ModalController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public function one()
1717
{
1818
SEO::title('Modal One');
1919

20-
return view('modal.one');
20+
return view('modal.one', [
21+
'closeExplicitly' => (bool) request()->query('closeExplicitly'),
22+
]);
2123
}
2224

2325
public function two()

app/resources/views/modal/base.blade.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Link modal dusk="validation" href="{{ route('modal.validation') }}">Open Modal Validation</Link>
1212
<Link modal dusk="libraries" href="{{ route('form.components.libraries') }}">Open Form Libraries</Link>
1313
<Link modal dusk="form-select" href="{{ route('form.components.customSelectOptions') }}">Open Custom Select Options</Link>
14+
<Link modal dusk="one-close-explicitly" href="{{ route('modal.one', ['closeExplicitly' => 1]) }}">Open Modal One (Close Explicitly)</Link>
1415
</div>
1516

1617
<div class="flex space-x-3">
@@ -42,7 +43,7 @@
4243
<div class="flex space-x-3">
4344
<Link dusk="menu-modal" href="#menu-modal">Preloaded modal</Link>
4445
<Link dusk="menu-slideover" href="#menu-slideover">Preloaded slideover</Link>
45-
<Link dusk="menu-modal-large" href="#menu-modal-large">Preloaded modal (large)</Link>
46+
<Link dusk="menu-modal-large" href="#menu-modal-large">Preloaded modal (large, close explicitly)</Link>
4647
<Link dusk="menu-slideover-large" href="#menu-slideover-large">Preloaded slideover (large)</Link>
4748
</div>
4849

@@ -54,7 +55,7 @@
5455
<h1>Check out my slideover!</h1>
5556
</x-splade-modal>
5657

57-
<x-splade-modal name="menu-modal-large" modal max-width="7xl">
58+
<x-splade-modal name="menu-modal-large" modal max-width="7xl" close-explicitly>
5859
<h1>Check out my modal!</h1>
5960
</x-splade-modal>
6061

app/resources/views/modal/one.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@section('content')
44

5-
<x-splade-modal>
5+
<x-splade-modal :close-explicitly="$closeExplicitly">
66
ModalComponentOne
77

88
<Link modal dusk="two" href="{{ route('modal.two') }}">Open Modal Two</Link>

app/tests/Browser/ModalTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ public function it_can_show_a_modal()
3030
});
3131
}
3232

33+
/** @test */
34+
public function it_can_require_the_modal_to_be_explicitly_closed()
35+
{
36+
$this->browse(function (Browser $browser) {
37+
$browser->visit('/modal/base')
38+
->resize(1024, 768)
39+
->waitForText('ModalComponent')
40+
->click('@one-close-explicitly')
41+
->waitForText('ModalComponentOne')
42+
->pause(500)
43+
->keys('', ['{escape}'])
44+
->pause(500)
45+
->assertSee('ModalComponentOne')
46+
->click('@close-one')
47+
->waitUntilMissingText('ModalComponentOne');
48+
});
49+
}
50+
3351
/** @test */
3452
public function it_can_do_nested_modals()
3553
{

app/tests/Browser/PreloadedModalTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function it_can_show_a_preloaded_slideover()
6060

6161
$browser
6262
->pause(500)
63-
->click('@close-modal-button')
63+
->keys('', ['{escape}'])
6464
->pause(500)
6565
->waitUntilMissingText('Check out my slideover!');
6666
});
@@ -88,6 +88,25 @@ public function it_can_show_a_large_preloaded_modal()
8888
});
8989
}
9090

91+
/** @test */
92+
public function it_can_disable_closing_the_model_implicitly()
93+
{
94+
$this->browse(function (Browser $browser) {
95+
$browser->visit('/modal/base')
96+
->resize(1680, 900)
97+
->waitForText('ModalComponent')
98+
->click('@menu-modal-large')
99+
->waitForText('Check out my modal!')
100+
->pause(500)
101+
->keys('', ['{escape}'])
102+
->pause(500)
103+
->assertSee('Check out my modal!')
104+
->click('@close-modal-button')
105+
->pause(500)
106+
->waitUntilMissingText('Check out my modal!');
107+
});
108+
}
109+
91110
/** @test */
92111
public function it_can_show_a_large_preloaded_slideover()
93112
{

resources/views/components/button.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<SpladeButton {{ $attributes->only(['v-bind:spinner', ':spinner']) }}>
44
<template #default="button">
5-
<button :disabled="button.spinner" {{ $attributes->class([
5+
<{{ $type === 'link' ? 'Link' : 'button' }} :disabled="button.spinner" {{ $attributes->class([
66
'border rounded-md shadow-sm font-bold py-2 px-4 focus:outline-none focus:ring focus:ring-opacity-50',
77
'bg-indigo-500 hover:bg-indigo-700 text-white border-transparent focus:border-indigo-300 focus:ring-indigo-200' => !$customStyling && $primary,
88
'bg-red-500 hover:bg-red-700 text-white border-transparent focus:border-red-700 focus:ring-red-200' => !$customStyling && $danger,
@@ -29,6 +29,6 @@ class="animate-spin mr-3 h-5 w-5 @if($secondary) text-gray-700 @else text-white
2929
</span>
3030
</div>
3131
@endif
32-
</button>
32+
</{{ $type === 'link' ? 'Link' : 'button' }}>
3333
</template>
3434
</SpladeButton>

resources/views/components/modal-wrapper.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<SpladeModal {{ $baseAttributes->mergeVueBinding(':close-button', $closeButton) }} :name="@js($name)">
33
<template #default="modal">
44
<x-splade-component is="transition" show="modal.isOpen">
5-
<x-splade-component is="dialog" v-bind:dusk="`modal.${modal.stack}`" close="modal.setIsOpen" class="relative z-20">
5+
<x-splade-component is="dialog" v-bind:dusk="`modal.${modal.stack}`" close="{{ $closeExplicitly ? '' : 'modal.setIsOpen' }}" class="relative z-20">
66
<!-- The backdrop, rendered as a fixed sibling to the panel container -->
77
<x-splade-component
88
is="transition" child

resources/views/components/modal.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<x-splade-component is="modal-wrapper" :base-attributes="$attributes->except('class')" :key="$modalKey" :close-button="$closeButton" :name="$name">
1+
<x-splade-component is="modal-wrapper" :base-attributes="$attributes->except('class')" :key="$modalKey" :close-button="$closeButton" :close-explicitly="$closeExplicitly" :name="$name">
22
<!-- Full-screen scrollable container -->
33
<div class="fixed inset-0 z-40 overflow-y-auto p-4">
44
<!-- Container to center the panel -->

resources/views/components/slideover.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<x-splade-component is="modal-wrapper" :base-attributes="$attributes->except('class')" :key="$modalKey" :close-button="$closeButton" :name="$name">
1+
<x-splade-component is="modal-wrapper" :base-attributes="$attributes->except('class')" :key="$modalKey" :close-button="$closeButton" :close-explicitly="$closeExplicitly" :name="$name">
22
<!-- Full-screen scrollable container -->
33
<div class="fixed inset-0 z-40 overflow-y-auto">
44
<!-- Container to center the panel -->

0 commit comments

Comments
 (0)