Files
breadcrumb-the-shire/templates/partials/app-flash.phtml
fs 1ba6829a1c fix: toast visibility — opaque backgrounds and flash scope matching with query strings
Two bugs in the toast redesign:

1. Variant backgrounds (success/warning/info/error) used rgba with 12-20%
   opacity, making toasts semi-transparent over page content. Fixed by
   layering the tint over a solid background via linear-gradient compositing.

2. Flash messages with scoped paths including query strings (e.g.
   edit pages with ?return=...) were not matched by Flash::peek(Request::path())
   since path() strips the query. Added fallback to pathWithQuery() matching.

Also moved flash partial before JS init scripts to ensure DOM is present
when the component runtime mounts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 19:58:15 +01:00

36 lines
1.2 KiB
PHTML

<?php
use MintyPHP\Support\Flash;
use MintyPHP\Http\Request;
use MintyPHP\Session;
$messages = Flash::peek(Request::path()) ?: Flash::peek(Request::pathWithQuery());
if (!$messages) {
return;
}
$returnTarget = Request::pathWithQuery();
$timeouts = [
'success' => 5000,
'info' => 6000,
'warning' => 7000,
'error' => 0,
];
?>
<div class="app-toast-stack" data-app-component="flash-auto-dismiss" aria-live="polite">
<?php foreach ($messages as $message) : ?>
<?php $type = $message['type'] ?? 'info'; ?>
<?php $timeout = $timeouts[$type] ?? 5000; ?>
<?php $isAssertive = $type === 'error' || $type === 'warning'; ?>
<div class="notice" data-variant="<?php e($type); ?>" data-flash-timeout="<?php e($timeout); ?>" role="<?php echo $isAssertive ? 'alert' : 'status'; ?>">
<span><?php e(t($message['message'] ?? '')); ?></span>
<form method="post" action="flash/dismiss/<?php e($message['id'] ?? ''); ?>">
<input type="hidden" name="return" value="<?php e($returnTarget); ?>">
<button type="submit" aria-label="<?php e(t('Dismiss')); ?>"><i class="bi bi-x-lg"></i></button>
<?php Session::getCsrfInput(); ?>
</form>
</div>
<?php endforeach; ?>
</div>