diff --git a/docs-assets/app/app/Http/Livewire/Actions.php b/docs-assets/app/app/Http/Livewire/Actions.php index 7a2087bfc7..01a98751f6 100644 --- a/docs-assets/app/app/Http/Livewire/Actions.php +++ b/docs-assets/app/app/Http/Livewire/Actions.php @@ -61,6 +61,15 @@ class Actions extends Component implements HasActions ->iconPosition('after'); } + public function confirmationModalAction(): Action + { + return Action::make('confirmationModalAction') + ->label('Delete') + ->color('danger') + ->requiresConfirmation() + ->action(fn () => null); + } + public function render() { return view('livewire.actions'); diff --git a/docs-assets/app/resources/views/livewire/actions.blade.php b/docs-assets/app/resources/views/livewire/actions.blade.php index bb53412832..660473596c 100644 --- a/docs-assets/app/resources/views/livewire/actions.blade.php +++ b/docs-assets/app/resources/views/livewire/actions.blade.php @@ -1,29 +1,39 @@ -
-
- {{ $this->buttonAction }} -
+
+ @if (! $this->mountedAction) +
+ {{ $this->buttonAction }} +
-
- {{ $this->linkAction }} -
+
+ {{ $this->linkAction }} +
-
- {{ $this->iconButtonAction }} -
+
+ {{ $this->iconButtonAction }} +
-
- {{ $this->dangerAction }} -
+
+ {{ $this->dangerAction }} +
-
- {{ $this->largeAction }} -
+
+ {{ $this->largeAction }} +
-
- {{ $this->iconAction }} -
+
+ {{ $this->iconAction }} +
-
- {{ $this->iconAfterAction }} +
+ {{ $this->iconAfterAction }} +
+ +
+ {{ $this->confirmationModalAction }} +
+ @endif + +
diff --git a/docs-assets/screenshots/images/actions/modal/confirmation.jpg b/docs-assets/screenshots/images/actions/modal/confirmation.jpg new file mode 100644 index 0000000000..7a5bed1fd9 Binary files /dev/null and b/docs-assets/screenshots/images/actions/modal/confirmation.jpg differ diff --git a/docs-assets/screenshots/schema.js b/docs-assets/screenshots/schema.js index eb363d6e0d..174545dda1 100644 --- a/docs-assets/screenshots/schema.js +++ b/docs-assets/screenshots/schema.js @@ -27,6 +27,21 @@ export default { url: 'actions', selector: '#iconAfterAction', }, + 'actions/modal/confirmation': { + url: 'actions', + viewport: { + width: 640, + height: 480, + deviceScaleFactor: 3, + }, + before: async (page, browser) => { + await page.click('#confirmationModalAction button') + await page.waitForSelector('#modal h2') + + await page.waitForTimeout(300) + }, + selector: 'body', + }, 'app/dashboard': { url: 'admin', selector: 'body', diff --git a/docs-assets/screenshots/script.js b/docs-assets/screenshots/script.js index 5b1378499a..86108a2838 100644 --- a/docs-assets/screenshots/script.js +++ b/docs-assets/screenshots/script.js @@ -27,6 +27,10 @@ for (const [file, options] of Object.entries(schema)) { waitUntil: 'networkidle2', }) + if (options.before) { + await options.before(page, browser) + } + const element = await page.waitForSelector(options.selector) await element.screenshot({ path: `images/${file}.jpg` }) diff --git a/packages/actions/docs/04-modals.md b/packages/actions/docs/04-modals.md index 2ece41e7ba..e479cab699 100644 --- a/packages/actions/docs/04-modals.md +++ b/packages/actions/docs/04-modals.md @@ -14,6 +14,8 @@ Action::make('delete') ->requiresConfirmation() ``` +![Confirmation modal](https://github.com/filamentphp/filament/blob/3.x/docs-assets/screenshots/images/actions/modal/confirmation.jpg?raw=true) + > Note: The confirmation modal is not available when a `url()` is set instead of an `action()`. Instead, you should redirect to the URL within the `action()` callback. ## Setting a modal heading, subheading, and button label @@ -136,4 +138,4 @@ Action::make('create') ->action('create') ->modalHidden(fn (): bool => $this->role !== 'admin') ->modalContent(view('filament.pages.actions.create')) -``` \ No newline at end of file +```