[6.x] Fix toasts being replayed on partial reloads - #15210
Merged
jasonvarga merged 1 commit intoAug 18, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a problem where toast messages on Inertia CP pages are replayed on every partial reload. We ran into this on a custom page that polls a queue via
usePoll(5000, { only: [...] })after aform.post()redirect. The success toast reappeared every 5 seconds until navigating away.The problem:
_toastsis shared as a regular Inertia prop, but it is flash data. Partial responses only contain the requested props, and Inertia merges them into the existing page props. So a stale_toastssurvives every partial reload, and thesuccesslistener inToasts.jsre-displays it each time.To reproduce the problem: Flash a toast on any CP page that uses
usePoll(…, { only: [...] }).See "Reproduction Code" down below.
The fix removes the prop from the page props once the toasts have been displayed, so a later partial reload has nothing left to replay.
An alternative approach would be to change toasts logic to Inertia's flash data (
Inertia::flash()). But that requires inertia-laravel >= 2.0.16 and touches the initial page load path (displayInitialToasts()). So it felt a bit too big of a change for this bugfix.Reproduction Code
Click the button: expected is one toast, actual is a toast every 3 seconds