Skip to content

Commit 54b9794

Browse files
committed
Rename jsAction() to actionJs()
1 parent 9d66024 commit 54b9794

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/actions/docs/01-overview.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ TextInput::make('slug')
519519

520520
### Running JavaScript when an action is clicked
521521

522-
If you need a simple action that runs JavaScript directly in the browser without making a network request, you can use the `jsAction()` method. This is useful for simple interactions like updating form field values instantly:
522+
If you need a simple action that runs JavaScript directly in the browser without making a network request, you can use the `actionJs()` method. This is useful for simple interactions like updating form field values instantly:
523523

524524
```php
525525
use Filament\Actions\Action;
@@ -529,7 +529,7 @@ TextInput::make('title')
529529
->live(onBlur: true)
530530
->afterContent(
531531
Action::make('generateSlug')
532-
->jsAction(<<<'JS'
532+
->actionJs(<<<'JS'
533533
$set('slug', $get('title').toLowerCase().replaceAll(' ', '-'))
534534
JS)
535535
)
@@ -539,14 +539,14 @@ TextInput::make('slug')
539539

540540
The JavaScript string has access to `$get()` and `$set()` utilities, which allow you to read and modify the state of form fields in the schema.
541541

542-
<UtilityInjection set="actions" version="4.x">As well as allowing a static value, the `jsAction()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
542+
<UtilityInjection set="actions" version="4.x">As well as allowing a static value, the `actionJs()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
543543

544544
<Aside variant="warning">
545-
When using `jsAction()`, the action cannot open a modal or perform any server-side processing. It is intended for simple client-side interactions only. If you need to run PHP code, use the `action()` method instead.
545+
When using `actionJs()`, the action cannot open a modal or perform any server-side processing. It is intended for simple client-side interactions only. If you need to run PHP code, use the `action()` method instead.
546546
</Aside>
547547

548548
<Aside variant="danger">
549-
Any JavaScript string passed to the `jsAction()` method will be executed in the browser, so you should never add user input directly into the string, as it could lead to cross-site scripting (XSS) vulnerabilities. User input from `$get()` should never be evaluated as JavaScript code, but is safe to use as a string value.
549+
Any JavaScript string passed to the `actionJs()` method will be executed in the browser, so you should never add user input directly into the string, as it could lead to cross-site scripting (XSS) vulnerabilities. User input from `$get()` should never be evaluated as JavaScript code, but is safe to use as a string value.
550550
</Aside>
551551

552552
## Action utility injection

packages/actions/src/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public function alpineClickHandler(string | Closure | null $handler): static
310310
return $this;
311311
}
312312

313-
public function jsAction(string | Closure | null $action): static
313+
public function actionJs(string | Closure | null $action): static
314314
{
315315
$this->alpineClickHandler($action);
316316

packages/forms/docs/01-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ TextInput::make('name')
637637
<AutoScreenshot name="forms/fields/below-content/action" alt="Form field with action below content" version="4.x" />
638638

639639
<Aside variant="tip">
640-
If you need a simple action that runs JavaScript without making a network request, you can use the [`jsAction()` method](../actions/overview#running-javascript-when-an-action-is-clicked). This is useful for simple interactions like updating form field values using `$get()` and `$set()`. Actions using `jsAction()` cannot open modals.
640+
If you need a simple action that runs JavaScript without making a network request, you can use the [`actionJs()` method](../actions/overview#running-javascript-when-an-action-is-clicked). This is useful for simple interactions like updating form field values using `$get()` and `$set()`. Actions using `actionJs()` cannot open modals.
641641
</Aside>
642642

643643
You can insert any combination of content into the slots by passing an array of content to the method:

0 commit comments

Comments
 (0)