Skip to content

Commit 6cbe695

Browse files
authored
fix: gracefully handle unresolvable actions when record state changes (#19401)
* gracefully handle unresolvable actions when record state changes * update * remove unmountAction call * use exists check * remove bulk action check * clear stale mounted actions in callers
1 parent d30efb2 commit 6cbe695

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/actions/src/Concerns/InteractsWithActions.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public function bootedInteractsWithActions(): void
9898

9999
// Boot the InteractsWithTable trait first so the table object is available.
100100
if (! ($this instanceof HasTable)) {
101-
$this->cacheMountedActions($this->mountedActions);
101+
if (empty($this->cacheMountedActions($this->mountedActions))) {
102+
$this->mountedActions = [];
103+
}
102104
}
103105
}
104106

@@ -480,7 +482,11 @@ public function getMountedAction(?int $actionNestingIndex = null): ?Action
480482
*/
481483
protected function cacheMountedActions(array $mountedActions): array
482484
{
483-
return $this->cachedMountedActions = $this->resolveActions($mountedActions);
485+
try {
486+
return $this->cachedMountedActions = $this->resolveActions($mountedActions);
487+
} catch (ActionNotResolvableException) {
488+
return $this->cachedMountedActions = [];
489+
}
484490
}
485491

486492
/**

packages/tables/src/Concerns/InteractsWithTable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public function bootedInteractsWithTable(): void
4848

4949
$this->cacheSchema('tableFiltersForm', $this->getTableFiltersForm(...));
5050

51-
$this->cacheMountedActions($this->mountedActions);
51+
if (empty($this->cacheMountedActions($this->mountedActions))) {
52+
$this->mountedActions = [];
53+
}
5254

5355
$this->initTableColumnManager();
5456

0 commit comments

Comments
 (0)