Skip to content

Server-side Toasts with a redirect creates a JS error #14797

@martyf

Description

@martyf

Bug description

I have a simple NavItem in my CP that just calls the route: the route does something, sends a "success" toast, and returns:

public function __invoke()
{
    // do some things

    Toast::success('Success!');

    return Inertia::back();
}

However, a JS error is thrown, and an empty array is send back as the Toast, resulting in the console error:

Uncaught TypeError: this[type] is not a function

The props for _toasts looks like:

{
	"_toasts": [
		[]
	]
}

How to reproduce

  1. Create a new Statamic site
  2. Create a simple CP controller (Controller file, and the route), and use the __invoke method above
  3. Add a Nav item via the AddonServiceProvider
  4. Visit the route in the CP

Logs

Environment

Environment
Laravel Version: 13.14.0
PHP Version: 8.4.22
Composer Version: 2.9.5
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Storage
public/storage: NOT LINKED

Livewire
Livewire: v4.3.1

Statamic
Addons: 0
License Key: Not set
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.20.2 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions