azgasim/filament-unsaved-changes-modal
Replaces Filament's browser confirmation dialog with a native Filament modal when leaving a dirty form. Works with SPA and full-page navigation, using the same dirty-state rules as unsavedChangesAlerts(). Requires Filament 5.3.5+ and PHP 8.2+.
confirm() and shows a Filament-styled Stay/Leave modal. It falls in the "make the admin panel feel like one coherent product" bucket, not the feature bucket.->unsavedChangesAlerts(), so the natural slot is an existing Filament upgrade or quality-of-life sprint where panel providers are already being touched. It is not worth its own release.livewire:navigate and full-page same-origin clicks, plus modal open/close by DOM id, plus translations, plus forever-maintenance against Filament upgrades — realistically a day plus carrying cost. Buying is composer require plus two lines. Buy, unless dependency policy blocks it.beforeLeave hook gives you inconsistent coverage and a maintenance tail — that asymmetry is the actual product argument here.Good fit when:
^5.3.5 (the floor is deliberate — earlier 5.x has a known XSS advisory) and PHP 8.2+.->unsavedChangesAlerts() or are willing to. Without it forms never register as dirty, no modal appears, and there is nothing in the logs — the single most common misconfiguration.en, de, ckb, fr — those ship today, and translations are the only way to change the copy.Look elsewhere when:
data-skip-unsaved-changes-modal escape hatch.Adoption terms if you proceed: pin the exact version in composer.lock, publish only the translations (avoid publishing views unless you must — a published view drifts from upstream markup), and treat the data-skip-unsaved-changes-modal attribute as a short deliberate list (cancel/discard links, logout, help-desk) rather than a default. Add one browser assertion per critical flow — dirty a form, click a nav link, assert the modal id appears, assert Leave actually reaches the target URL — because composer test covers the package, not your integration.
To executives (one paragraph): A small, free, MIT-licensed add-on for our admin panel that replaces the browser's blocking "are you sure you want to leave" popup with a modal that matches our product's look, and gives users a clear Stay/Leave choice. Cost is roughly one engineering hour plus a test; it is reversible by removing a single line. It reduces a recurring class of "I lost my work" support tickets and makes the panel look finished to anyone who sees it. It does not fix data loss on reload — autosave remains a separate, larger decision.
To engineering (the detail that matters):
composer require, then both ->unsavedChangesAlerts() and ->plugin(FilamentUnsavedChangesModalPlugin::make()) on the panel. Dropping either one produces silence, not an error.final plugin class — five fluent setters for width, icon, icon color, and the two button colors, plus MODAL_DOM_ID. No config file (removed as a breaking change in 1.0.0); theme via the fluent chain so the visual contract is one reviewable diff.navigation.* in translations; publish and edit as normal app copy rather than patching views.livewire:navigate) and same-origin full-page links. data-skip-unsaved-changes-modal on a link or any ancestor exempts a cluster via closest(...).Risk to state plainly, not bury: 12 stars, 0 dependents, a single maintainer, and a Filament-major-coupled version constraint. That is fine for a UI-only swap of this size, but classify it as a forkable utility, not infrastructure: pin the version, keep the escape hatch minimal, and put it on the list to re-evaluate at the next Filament major. If the project stalls, taking over a few hundred MIT lines is a bounded afternoon — which is exactly why the buy decision is safe here.
How can I help you explore Laravel packages today?