Files
xamxam/app/public/admin/toast-fragment.php
Pontoporeia 5f24dcae7e fix: duplicate warning not shown in admin, double-encoded in partage, no focus
- toast-fragment.php: 204 early-exit now also checks flash['warning'];
  previously the warning was consumed by consumeFlash() then silently dropped
- partage/index.php: store warning as plain text; htmlspecialchars() applied
  once at render time — previously htmlspecialchars() was called inside the
  stored string then again at output, producing ' entities etc.
- partage/index.php: flash-warning div gets id + tabindex=-1; inline JS
  scrolls it into view and focuses it on DOMContentLoaded
- admin/footer.php: htmx:afterSettle listener focuses .toast--warning after
  HTMX injects the toast fragment into #toast-region
2026-05-05 11:04:52 +02:00

22 lines
582 B
PHP

<?php
/**
* Toast fragment endpoint — HTMX target.
*
* Reads flash messages from the session and returns the toast markup.
* Returns an empty 204 when there is nothing to show.
* Called via hx-get on the #toast-region aside in the admin footer.
*/
require_once __DIR__ . '/../../bootstrap.php';
require_once __DIR__ . '/../../src/AdminAuth.php';
AdminAuth::requireLogin();
$flash = App::consumeFlash();
if (!$flash['error'] && !$flash['success'] && !$flash['warning']) {
http_response_code(204);
exit;
}
include APP_ROOT . '/templates/admin/partials/toast.php';