Skip to content

Upgrade Sweet Alert to v8 - #112

Merged
rbruhn merged 1 commit into
developmentfrom
109-sweet-alert-8
Oct 21, 2026
Merged

rbruhn merged 1 commit into
developmentfrom
109-sweet-alert-8

Conversation

@rbruhn

@rbruhn rbruhn commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Replaces #109. That Dependabot PR only bumped composer.json, and v8 is a rewrite, so on its own it broke every page (Target class [RealRashid\SweetAlert\ToSweetAlert] does not exist) and would have stopped the deploy.

Changes

  • Package: realrashid/sweet-alert 7.3.2 → 8.0.0.
  • Middleware: ToSweetAlert moved to RealRashid\SweetAlert\Http\Middleware\ToSweetAlert (bootstrap/app.php). It still turns the toast_success / toast_error flashes from the contact form and the honeypot into toasts. Pint also replaced the fully qualified class names in that file with imports.
  • Config: config/sweetalert.php is the v8 file, because v8 renamed most keys (alwaysLoadJS → always_load_js, and so on). The toast settings keep this site's v7 values: position top, auto close on, 5 seconds. Validation errors still show as toasts, as before.
    • The timer environment variable is now SWEET_ALERT_MIDDLEWARE_TIMER (was SWEET_ALERT_MIDDLEWARE_ALERT_CLOSE_TIME). No environment file here sets either.
  • View: removed the old published copy, resources/views/vendor/sweetalert/alert.blade.php, which came from an earlier version and loaded sweetalert.all.js. The layout uses v8's @sweetAlert directive. v8's view loads SweetAlert2 from jsDelivr and the package's vendor/sweetalert/sweet-alert.js.
  • Deploy: v8 renamed sweetalert:publish to alert:publish. The task is now artisan:alert:publish, running php artisan alert:publish --assets --force, which publishes public/vendor/sweetalert/sweet-alert.js into each release (public/vendor isn't in git).

php artisan alert:upgrade --dry-run reports nothing left to rewrite.

Tests

  • ContactFormTest: new test that, after sending the contact form, the page the user lands on loads sweet-alert.js and shows "Contact message sent successfully." It fails without the middleware.
  • vendor/bin/pest --compact: 49 passed, 2 skipped. php artisan view:cache and yarn run production succeed.

To verify on development

  • The deploy's artisan:alert:publish step succeeds, and public/vendor/sweetalert/sweet-alert.js exists in the new release.
  • Sending the contact form shows the green "Contact message sent successfully." toast at the top, and it closes after about 5 seconds.
  • No console errors on the contact page.

@rbruhn rbruhn self-assigned this Oct 21, 2026
@rbruhn
rbruhn merged commit f9cd75d into development Oct 21, 2026
2 checks passed
@rbruhn
rbruhn deleted the 109-sweet-alert-8 branch October 21, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant