mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Rename slightly
This commit is contained in:
@@ -552,9 +552,9 @@ use Filament\Support\View\Components\Modal;
|
||||
Modal::closeButton(false);
|
||||
```
|
||||
|
||||
## Disable autofocus on modal open
|
||||
## Preventing the modal from autofocusing
|
||||
|
||||
By default, modals will autofocus on the first focusable element when opened. If you wish to disable this behavior for the modal you can use the `modalAutofocus(false)` method:
|
||||
By default, modals will autofocus on the first focusable element when opened. If you wish to disable this behavior, you can use the `modalAutofocus(false)` method:
|
||||
|
||||
```php
|
||||
Action::make('updateAuthor')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<x-filament::modal
|
||||
:alignment="$action?->getModalAlignment()"
|
||||
:autofocus="$action?->autofocusOnOpen()"
|
||||
:autofocus="$action?->isModalAutofocused()"
|
||||
:close-button="$action?->hasModalCloseButton()"
|
||||
:close-by-clicking-away="$action?->isModalClosedByClickingAway()"
|
||||
:close-by-escaping="$action?->isModalClosedByEscaping()"
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
<x-filament::modal
|
||||
:alignment="$action?->getModalAlignment()"
|
||||
:autofocus="$action?->autofocusOnOpen()"
|
||||
:autofocus="$action?->isModalAutofocused()"
|
||||
:close-button="$action?->hasModalCloseButton()"
|
||||
:close-by-clicking-away="$action?->isModalClosedByClickingAway()"
|
||||
:close-by-escaping="$action?->isModalClosedByEscaping()"
|
||||
@@ -124,7 +124,7 @@
|
||||
|
||||
<x-filament::modal
|
||||
:alignment="$action?->getModalAlignment()"
|
||||
:autofocus="$action?->autofocusOnOpen()"
|
||||
:autofocus="$action?->isModalAutofocused()"
|
||||
:close-button="$action?->hasModalCloseButton()"
|
||||
:close-by-clicking-away="$action?->isModalClosedByClickingAway()"
|
||||
:close-by-escaping="$action?->isModalClosedByEscaping()"
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
<x-filament::modal
|
||||
:alignment="$action?->getModalAlignment()"
|
||||
:autofocus="$action?->autofocusOnOpen()"
|
||||
:autofocus="$action?->isModalAutofocused()"
|
||||
:close-button="$action?->hasModalCloseButton()"
|
||||
:close-by-clicking-away="$action?->isModalClosedByClickingAway()"
|
||||
:close-by-escaping="$action?->isModalClosedByEscaping()"
|
||||
@@ -248,7 +248,7 @@
|
||||
<form wire:submit.prevent="callMountedFormComponentAction">
|
||||
<x-filament::modal
|
||||
:alignment="$action?->getModalAlignment()"
|
||||
:autofocus="$action?->autofocusOnOpen()"
|
||||
:autofocus="$action?->isModalAutofocused()"
|
||||
:close-button="$action?->hasModalCloseButton()"
|
||||
:close-by-clicking-away="$action?->isModalClosedByClickingAway()"
|
||||
:close-by-escaping="$action?->isModalClosedByEscaping()"
|
||||
|
||||
@@ -82,7 +82,7 @@ trait CanOpenModal
|
||||
|
||||
protected bool | Closure | null $isModalClosedByEscaping = null;
|
||||
|
||||
protected bool | Closure | null $autofocusOnOpen = null;
|
||||
protected bool | Closure | null $isModalAutofocused = null;
|
||||
|
||||
protected string | Closure | null $modalIcon = null;
|
||||
|
||||
@@ -133,7 +133,7 @@ trait CanOpenModal
|
||||
|
||||
public function modalAutofocus(bool | Closure | null $condition = true): static
|
||||
{
|
||||
$this->autofocusOnOpen = $condition;
|
||||
$this->isModalAutofocused = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -623,9 +623,9 @@ trait CanOpenModal
|
||||
return (bool) ($this->evaluate($this->isModalClosedByEscaping) ?? Modal::$isClosedByEscaping);
|
||||
}
|
||||
|
||||
public function autofocusOnOpen(): bool
|
||||
public function isModalAutofocused(): bool
|
||||
{
|
||||
return $this->evaluate($this->autofocusOnOpen) ?? Modal::$autofocusOnOpen;
|
||||
return $this->evaluate($this->isModalAutofocused) ?? Modal::$isAutofocused;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -195,6 +195,16 @@ By default, when you click away from a modal, it will close itself. If you wish
|
||||
</x-filament::modal>
|
||||
```
|
||||
|
||||
## Closing the modal by escaping
|
||||
|
||||
By default, when you press escape on a modal, it will close itself. If you wish to disable this behavior for a specific action, you can use the `close-by-escaping` attribute:
|
||||
|
||||
```blade
|
||||
<x-filament::modal :close-by-escaping="false">
|
||||
{{-- Modal content --}}
|
||||
</x-filament::modal>
|
||||
```
|
||||
|
||||
## Hiding the modal close button
|
||||
|
||||
By default, modals have a close button in the top right corner. You can remove the close button from the modal by using the `close-button` attribute:
|
||||
@@ -205,9 +215,9 @@ By default, modals have a close button in the top right corner. You can remove t
|
||||
</x-filament::modal>
|
||||
```
|
||||
|
||||
## Disable autofocus on modal open
|
||||
## Preventing the modal from autofocusing
|
||||
|
||||
By default, modals will autofocus on the first focusable element when opened. If you wish to disable this behavior for the modal you can use the `autofocus` attribute:
|
||||
By default, modals will autofocus on the first focusable element when opened. If you wish to disable this behavior, you can use the `autofocus` attribute:
|
||||
|
||||
```blade
|
||||
<x-filament::modal :autofocus="false">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@props([
|
||||
'alignment' => Alignment::Start,
|
||||
'ariaLabelledby' => null,
|
||||
'autofocus' => \Filament\Support\View\Components\Modal::$autofocusOnOpen,
|
||||
'autofocus' => \Filament\Support\View\Components\Modal::$isAutofocused,
|
||||
'closeButton' => \Filament\Support\View\Components\Modal::$hasCloseButton,
|
||||
'closeByClickingAway' => \Filament\Support\View\Components\Modal::$isClosedByClickingAway,
|
||||
'closeByEscaping' => \Filament\Support\View\Components\Modal::$isClosedByEscaping,
|
||||
@@ -96,11 +96,7 @@
|
||||
x-on:{{ $closeEventName }}.window="if ($event.detail.id === '{{ $id }}') close()"
|
||||
x-on:{{ $openEventName }}.window="if ($event.detail.id === '{{ $id }}') open()"
|
||||
@endif
|
||||
@if ($autofocus)
|
||||
x-trap.noscroll="isOpen"
|
||||
@else
|
||||
x-trap.noscroll.noautofocus="isOpen"
|
||||
@endif
|
||||
x-trap.noscroll{{ $autofocus ? '' : '.noautofocus' }}="isOpen"
|
||||
x-bind:class="{
|
||||
'fi-modal-open': isOpen,
|
||||
}"
|
||||
|
||||
@@ -10,7 +10,12 @@ class Modal
|
||||
|
||||
public static bool $isClosedByEscaping = true;
|
||||
|
||||
public static bool $autofocusOnOpen = true;
|
||||
public static bool $isAutofocused = true;
|
||||
|
||||
public static function autofocus(bool $condition = true): void
|
||||
{
|
||||
static::$isAutofocused = $condition;
|
||||
}
|
||||
|
||||
public static function closeButton(bool $condition = true): void
|
||||
{
|
||||
@@ -26,9 +31,4 @@ class Modal
|
||||
{
|
||||
static::$isClosedByEscaping = $condition;
|
||||
}
|
||||
|
||||
public static function autofocuces(bool $condition = true): void
|
||||
{
|
||||
static::$autofocusOnOpen = $condition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
@if (($layout === FiltersLayout::Modal) || $triggerAction->isModalSlideOver())
|
||||
<x-filament::modal
|
||||
:alignment="$triggerAction->getModalAlignment()"
|
||||
:autofocus="$triggerAction->autofocusOnOpen()"
|
||||
:autofocus="$triggerAction->isAutofocused()"
|
||||
:close-button="$triggerAction->hasModalCloseButton()"
|
||||
:close-by-clicking-away="$triggerAction->isModalClosedByClickingAway()"
|
||||
:close-by-escaping="$triggerAction?->isModalClosedByEscaping()"
|
||||
:description="$triggerAction->getModalDescription()"
|
||||
:footer-actions="$triggerAction->getVisibleModalFooterActions()"
|
||||
:footer-actions-alignment="$triggerAction->getModalFooterActionsAlignment()"
|
||||
|
||||
Reference in New Issue
Block a user