diff --git a/src/Heimdall.Web/Components/Pages/SnapshotsPage.razor b/src/Heimdall.Web/Components/Pages/SnapshotsPage.razor
index 2935b04..b801c62 100644
--- a/src/Heimdall.Web/Components/Pages/SnapshotsPage.razor
+++ b/src/Heimdall.Web/Components/Pages/SnapshotsPage.razor
@@ -55,30 +55,32 @@ else
}
-@if (_lightboxEvent is not null)
-{
-
-
-
- @FormatEventType(_lightboxEvent.Type) · @_lightboxEvent.OccurredAt.ToLocalTime().ToString("g")
- Voir la caméra
-
-
-
-
- @if (!string.IsNullOrEmpty(_lightboxEvent.Label))
- {
- @_lightboxEvent.Label
- }
-
- Confiance : @_lightboxEvent.Confidence.ToString("P0") · ID : @_lightboxEvent.Id.ToString()[..8]
-
-
-
- Fermer
-
-
-}
+@* Lightbox toujours rendu : la visibilité est pilotée uniquement par @bind-Visible.
+ Le pattern @if (_lightboxEvent is not null) { } détruisait le composant
+ au lieu de le cacher → dialog orphelin, bouton Fermer inopérant (issue #94).
+ Le contenu n'est rendu que quand le dialog est visible (OpenLightbox définit
+ _lightboxEvent avant de passer _showLightbox à true) — accès via `!`. *@
+
+
+
+ @FormatEventType(_lightboxEvent!.Type) · @_lightboxEvent!.OccurredAt.ToLocalTime().ToString("g")
+ Voir la caméra
+
+
+
+
+ @if (!string.IsNullOrEmpty(_lightboxEvent!.Label))
+ {
+ @_lightboxEvent!.Label
+ }
+
+ Confiance : @_lightboxEvent!.Confidence.ToString("P0") · ID : @_lightboxEvent!.Id.ToString()[..8]
+
+
+
+ Fermer
+
+
@implements IDisposable
diff --git a/tests/Heimdall.Web.Tests/Components/Pages/SnapshotsPageTests.cs b/tests/Heimdall.Web.Tests/Components/Pages/SnapshotsPageTests.cs
index 170d1a0..2b9aa1d 100644
--- a/tests/Heimdall.Web.Tests/Components/Pages/SnapshotsPageTests.cs
+++ b/tests/Heimdall.Web.Tests/Components/Pages/SnapshotsPageTests.cs
@@ -95,4 +95,55 @@ public class SnapshotsPageTests : PageTestBase
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Voir la caméra"));
}
+
+ [Fact]
+ public void SnapshotsPage_FermerLightbox_LeDialogSeFerme()
+ {
+ // Régression issue #94 : le MudDialog était enveloppé dans un @if →
+ // Visible=false détruisait le composant au lieu de le cacher, le dialog
+ // restait orphelin et le bouton Fermer ne répondait plus.
+ Handler.OnGet("api/events", new EventPageResult(
+ [SnapshotEvent("PersonDetected", 0.87, "Personne", "/snapshots/1.jpg")], 1, 1, 100));
+ LoginAs();
+
+ var cut = RenderPage();
+ cut.WaitForAssertion(() => cut.Markup.ShouldContain("Personne · 87%"));
+
+ // Ouvrir la lightbox.
+ cut.FindAll("div[role=button]")[0].Click();
+ cut.WaitForAssertion(() => cut.Markup.ShouldContain("Voir la caméra"));
+
+ // Cliquer Fermer → le dialog disparaît du markup (le composant reste
+ // rendu mais Visible=false, le MudDialogProvider ne l'affiche plus).
+ cut.FindAll("button").Single(b => b.TextContent.Contains("Fermer")).Click();
+
+ cut.WaitForAssertion(() => cut.Markup.ShouldNotContain("Voir la caméra"));
+ }
+
+ [Fact]
+ public void SnapshotsPage_LeDialogResteRenduApresFermeture()
+ {
+ // Cœur de la régression issue #94 : le MudDialog ne doit jamais être
+ // détruit par un @if — il reste rendu, Visible piloté par @bind-Visible.
+ // Avec l'ancien pattern, FindComponents() retournait 0 hors
+ // ouverture (le @if (_lightboxEvent is not null) détruisait le composant).
+ Handler.OnGet("api/events", new EventPageResult(
+ [SnapshotEvent("PersonDetected", 0.87, "Personne", "/snapshots/1.jpg")], 1, 1, 100));
+ LoginAs();
+
+ var cut = RenderPage();
+ cut.WaitForAssertion(() => cut.Markup.ShouldContain("Personne · 87%"));
+
+ // Dialog présent dans l'arbre dès le rendu initial, alors que le
+ // lightbox est fermé (Visible=false).
+ cut.FindComponents().Count.ShouldBe(1);
+
+ // Ouvrir puis fermer : le composant MudDialog reste dans l'arbre.
+ cut.FindAll("div[role=button]")[0].Click();
+ cut.WaitForAssertion(() => cut.Markup.ShouldContain("Voir la caméra"));
+ cut.FindAll("button").Single(b => b.TextContent.Contains("Fermer")).Click();
+ cut.WaitForAssertion(() => cut.Markup.ShouldNotContain("Voir la caméra"));
+
+ cut.FindComponents().Count.ShouldBe(1);
+ }
}