fix(dashboard): pilot native dialog focus and safe dismissal

This commit is contained in:
Joseph Doherty
2026-11-13 17:51:02 -05:00
parent 3e004708d4
commit 260d58afa1
32 changed files with 1750 additions and 40 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

@@ -0,0 +1,531 @@
{
"cases": [
{
"width": 1440,
"dpr": 1,
"scroll": 1440,
"zoom": 1,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "TEXTAREA",
"id": "readSubtrees",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId",
"documentHasFocus": true
}
],
"validationInsideDialog": true
},
{
"width": 1024,
"dpr": 1,
"scroll": 1024,
"zoom": 1,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "TEXTAREA",
"id": "readSubtrees",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId",
"documentHasFocus": true
}
],
"validationInsideDialog": true
},
{
"width": 390,
"dpr": 1,
"scroll": 390,
"zoom": 1,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "TEXTAREA",
"id": "readSubtrees",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId",
"documentHasFocus": true
}
],
"validationInsideDialog": true
},
{
"width": 720,
"dpr": 2,
"scroll": 720,
"zoom": 2,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "TEXTAREA",
"id": "readSubtrees",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName",
"documentHasFocus": true
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId",
"documentHasFocus": true
}
],
"validationInsideDialog": true
}
],
"slowBusyEscapeSingleDispatch": true,
"servedThemeCssSha256": "7a6da7aefcf036f971f18816e3ceb129f1abb4a39f6db33d449420b814cfb4a6",
"errors": []
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

@@ -0,0 +1,451 @@
{
"cases": [
{
"width": 1440,
"dpr": 1,
"scroll": 1440,
"zoom": 1,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": false,
"tag": "BODY",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
}
],
"validationInsideDialog": true
},
{
"width": 1024,
"dpr": 1,
"scroll": 1024,
"zoom": 1,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": false,
"tag": "BODY",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
}
],
"validationInsideDialog": true
},
{
"width": 390,
"dpr": 1,
"scroll": 390,
"zoom": 1,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": false,
"tag": "BODY",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
}
],
"validationInsideDialog": true
},
{
"width": 720,
"dpr": 2,
"scroll": 720,
"zoom": 2,
"nativeModal": true,
"outsideFocusBlocked": true,
"focusSamples": [
{
"inside": false,
"tag": "BODY",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": ""
},
{
"inside": true,
"tag": "INPUT",
"id": "displayName"
},
{
"inside": true,
"tag": "INPUT",
"id": "keyId"
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
},
{
"inside": true,
"tag": "BUTTON",
"id": ""
}
],
"validationInsideDialog": true
}
],
"slowBusyEscapeSingleDispatch": true,
"servedThemeCssSha256": "7a6da7aefcf036f971f18816e3ceb129f1abb4a39f6db33d449420b814cfb4a6",
"errors": []
}
@@ -0,0 +1,8 @@
{
"pendingImportHidden": true,
"disposeBeforeImportCompletionNoResurrection": true,
"reopenAfterDisposal": true,
"connectedDisabledTriggerFallsBackToHeading": true,
"headingTabindexRemovedOnBlur": true,
"subsequentInstanceOpensAndCancels": true
}
@@ -0,0 +1,9 @@
{
"baseline": 341,
"after": 343,
"removed": [],
"added": [
"ZB.MOM.WW.MxGateway.Tests.Dashboard.ConfirmDialogRenderTests.BusyConfirmation_ExposesBusyStateAndRetainsDisabledActions",
"ZB.MOM.WW.MxGateway.Tests.Dashboard.ConfirmDialogRenderTests.RequestedConfirmation_RendersNamedNativeDialogAndSafeCancel"
]
}
@@ -0,0 +1,6 @@
{
"version": "1.0.1",
"sha256": "995b117b0245577598c91404ed7957c071ebe3413696c8be48b419c9deb1bd5d",
"source": "https://gitea.dohertylan.com/api/packages/dohertj2/nuget/index.json",
"servedCssSha256": "7a6da7aefcf036f971f18816e3ceb129f1abb4a39f6db33d449420b814cfb4a6"
}
@@ -0,0 +1,53 @@
[
{
"alert": {
"top": 80.390625,
"bottom": 134.78125
},
"dialog": {
"top": 16,
"bottom": 884
},
"body": null,
"visible": true,
"width": 1440,
"zoom": 1,
"initialKeyIdVisible": true,
"tabSamples": 60,
"chromeSamples": 1
},
{
"alert": {
"top": 80.390625,
"bottom": 134.78125
},
"dialog": {
"top": 16,
"bottom": 884
},
"body": null,
"visible": true,
"width": 390,
"zoom": 1,
"initialKeyIdVisible": true,
"tabSamples": 60,
"chromeSamples": 1
},
{
"alert": {
"top": 80.3984375,
"bottom": 134.796875
},
"dialog": {
"top": 16,
"bottom": 434
},
"body": null,
"visible": true,
"width": 720,
"zoom": 2,
"initialKeyIdVisible": true,
"tabSamples": 60,
"chromeSamples": 2
}
]
@@ -0,0 +1,62 @@
[
{
"alert": {
"top": -320.609375,
"bottom": -266.21875
},
"dialog": {
"top": 16,
"bottom": 884
},
"body": {
"top": 80.390625,
"bottom": 883
},
"visible": false,
"width": 1440,
"zoom": 1,
"initialKeyIdVisible": true,
"tabSamples": 60,
"chromeSamples": 1
},
{
"alert": {
"top": -665.609375,
"bottom": -611.21875
},
"dialog": {
"top": 16,
"bottom": 884
},
"body": {
"top": 80.390625,
"bottom": 883
},
"visible": false,
"width": 390,
"zoom": 1,
"initialKeyIdVisible": true,
"tabSamples": 60,
"chromeSamples": 1
},
{
"alert": {
"top": -840.6015625,
"bottom": -786.203125
},
"dialog": {
"top": 16,
"bottom": 434
},
"body": {
"top": 80.3984375,
"bottom": 433
},
"visible": false,
"width": 720,
"zoom": 2,
"initialKeyIdVisible": true,
"tabSamples": 60,
"chromeSamples": 2
}
]
@@ -0,0 +1,2 @@
@namespace MxUiCanary.Components
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><base href="/"/><link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css"/><ThemeHead/><link rel="stylesheet" href="/css/site.css"/></head><body class="dashboard-body"><FixtureBody @rendermode="InteractiveServer"/><script>window.mxCanaryReady=()=>document.documentElement.dataset.mxReady='true';</script><script src="/_framework/blazor.web.js"></script></body></html>
@@ -0,0 +1,18 @@
@namespace MxUiCanary.Components
@page "/"
@inject IJSRuntime JS
<ThemeShell Product="Synthetic MX UI canary">
<ChildContent>
<p>Synthetic local fixture: no gateway worker, key store, LDAP, COM or real write provider.</p>
<button id="slow-trigger" class="btn btn-secondary" @onclick="()=>_open=true">Open synthetic delayed confirmation</button>
<button id="outside" class="btn btn-secondary">Outside inertness probe</button>
<p id="counts">Synthetic confirms: @_count</p>
<ConfirmDialog IsOpen="@_open" IsBusy="@_busy" Title="Synthetic delayed operation" Message="Fixture only; no session or key is changed." OnCancel="()=>_open=false" OnConfirm="Confirm"/>
<ApiKeysPage/>
</ChildContent>
</ThemeShell>
@code {
bool _open;bool _busy;int _count;
protected override async Task OnAfterRenderAsync(bool firstRender) {if(firstRender)await JS.InvokeVoidAsync("mxCanaryReady");}
async Task Confirm(){if(_busy)return;_busy=true;_count++;await Task.Delay(1500);_busy=false;_open=false;}
}
@@ -0,0 +1,7 @@
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using ZB.MOM.WW.Theme
@using ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Shared
@using ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Pages
+105
View File
@@ -0,0 +1,105 @@
using System.Runtime.CompilerServices;
using System.Security.Claims;
using Microsoft.AspNetCore.Components.Authorization;
using ZB.MOM.WW.MxGateway.Server.Dashboard;
using ZB.MOM.WW.MxGateway.Server.Security.Authentication;
using ZB.MOM.WW.MxGateway.Server.Security.Authorization;
internal sealed class StubSnapshotService : IDashboardSnapshotService
{
/// <inheritdoc />
public DashboardSnapshot GetSnapshot() => new(
GeneratedAt: DateTimeOffset.UnixEpoch,
GatewayStartedAt: DateTimeOffset.UnixEpoch,
GatewayUptime: TimeSpan.Zero,
GatewayStatus: "Healthy",
GatewayVersion: "test",
Sessions: [],
Workers: [],
Metrics: [],
Faults: [],
ApiKeys:
[
new DashboardApiKeySummary(
KeyId: "synthetic-tagged",
DisplayName: "Tags only",
Scopes: new HashSet<string>(StringComparer.Ordinal),
Constraints: ApiKeyConstraints.Empty with { DashboardTags = ["team-a", "team-b"] },
CreatedUtc: DateTimeOffset.UnixEpoch,
LastUsedUtc: null,
RevokedUtc: null),
new DashboardApiKeySummary(
KeyId: "synthetic-plain",
DisplayName: "Unconstrained",
Scopes: new HashSet<string>(StringComparer.Ordinal),
Constraints: ApiKeyConstraints.Empty,
CreatedUtc: DateTimeOffset.UnixEpoch,
LastUsedUtc: null,
RevokedUtc: null),
],
Configuration: null!,
Galaxy: null!);
/// <inheritdoc />
public IAsyncEnumerable<DashboardSnapshot> WatchSnapshotsAsync(CancellationToken cancellationToken) =>
new IdleSnapshotFeed().WatchAsync(cancellationToken);
}
// Parks until the page is disposed, so the base page's watch loop neither spins nor pushes a
// second snapshot mid-render.
internal sealed class IdleSnapshotFeed : IDashboardSnapshotFeed
{
/// <inheritdoc />
public async IAsyncEnumerable<DashboardSnapshot> WatchAsync(
[EnumeratorCancellation] CancellationToken cancellationToken)
{
await Task.Delay(Timeout.Infinite, cancellationToken).ConfigureAwait(false);
yield break;
}
}
// Grants management so the create dialog is reachable; no test here exercises a mutation.
internal sealed class ManagingApiKeyService : IDashboardApiKeyManagementService
{
/// <inheritdoc />
public bool CanManage(ClaimsPrincipal user) => true;
/// <inheritdoc />
public Task<DashboardApiKeyManagementResult> CreateAsync(
ClaimsPrincipal user,
DashboardApiKeyManagementRequest request,
CancellationToken cancellationToken) =>
Task.FromResult(DashboardApiKeyManagementResult.Fail("not exercised"));
/// <inheritdoc />
public Task<DashboardApiKeyManagementResult> RevokeAsync(
ClaimsPrincipal user,
string keyId,
CancellationToken cancellationToken) =>
Task.FromResult(DashboardApiKeyManagementResult.Fail("not exercised"));
/// <inheritdoc />
public Task<DashboardApiKeyManagementResult> RotateAsync(
ClaimsPrincipal user,
string keyId,
CancellationToken cancellationToken) =>
Task.FromResult(DashboardApiKeyManagementResult.Fail("not exercised"));
/// <inheritdoc />
public Task<DashboardApiKeyManagementResult> DeleteAsync(
ClaimsPrincipal user,
string keyId,
CancellationToken cancellationToken) =>
Task.FromResult(DashboardApiKeyManagementResult.Fail("not exercised"));
}
internal sealed class StubAuthenticationStateProvider : AuthenticationStateProvider
{
/// <inheritdoc />
public override Task<AuthenticationState> GetAuthenticationStateAsync() =>
Task.FromResult(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(
[new Claim(ClaimTypes.Name, "admin-user"), new Claim(ClaimTypes.Role, DashboardRoles.Admin)],
authenticationType: "test",
nameType: ClaimTypes.Name,
roleType: ClaimTypes.Role))));
}
@@ -0,0 +1,2 @@
<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>net10.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup><ItemGroup><ProjectReference Include="../../../src/ZB.MOM.WW.MxGateway.Server/ZB.MOM.WW.MxGateway.Server.csproj" /></ItemGroup>
<Target Name="DeduplicateFixtureFrameworkAssets" BeforeTargets="ResolveBuildCompressedStaticWebAssetsConfiguration"><RemoveDuplicates Inputs="@(StaticWebAsset)"><Output TaskParameter="Filtered" ItemName="_UniqueFixtureStaticWebAsset" /></RemoveDuplicates><ItemGroup><StaticWebAsset Remove="@(StaticWebAsset)" /><StaticWebAsset Include="@(_UniqueFixtureStaticWebAsset)" /></ItemGroup></Target></Project>
+18
View File
@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.FileProviders;
using MxUiCanary.Components;
using ZB.MOM.WW.MxGateway.Server.Dashboard;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://127.0.0.1:0");
builder.WebHost.UseStaticWebAssets();
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
builder.Services.AddSingleton<IDashboardSnapshotService, StubSnapshotService>();
builder.Services.AddSingleton<IDashboardSnapshotFeed, IdleSnapshotFeed>();
builder.Services.AddSingleton<IDashboardApiKeyManagementService, ManagingApiKeyService>();
builder.Services.AddSingleton<AuthenticationStateProvider, StubAuthenticationStateProvider>();
var app = builder.Build();
app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.GetFullPath("../../../src/ZB.MOM.WW.MxGateway.Server/wwwroot")) });
app.UseStaticFiles();app.UseAntiforgery();
app.MapRazorComponents<FixtureApp>().AddInteractiveServerRenderMode();
app.MapGet("/provenance",()=>new { theme=typeof(ZB.MOM.WW.Theme.ThemeShell).Assembly.GetName().Version?.ToString(), syntheticOnly=true });
app.Run();
@@ -0,0 +1,43 @@
"""Actual MX components; fixture-only services, no production operations."""
import json,sys,hashlib
from pathlib import Path
from playwright.sync_api import sync_playwright
ROOT=Path(__file__).resolve().parent
sys.path.insert(0,'/Users/dohertj2/.codex/worktrees/scada-ui-consistency/scadaproj/components/ui-theme/validation/theme-1.0.0/canary')
from browser_zoom import zoom_browser,set_browser_zoom
BASE=json.load(open('/tmp/mx-ui-canary-state.json'))['origin'];OUT=ROOT/'evidence/mx02/browser-confirmation';OUT.mkdir(exist_ok=True)
results=[];errors=[]
with sync_playwright() as p:
with zoom_browser(p) as (ctx,worker):
page=ctx.new_page();page.on('pageerror',lambda e:errors.append(str(e)))
for width,zoom in [(1440,1),(1024,1),(390,1),(1440,2)]:
page.set_viewport_size({'width':width,'height':900});page.goto(BASE);page.wait_for_selector('html[data-mx-ready="true"]');page.evaluate('document.fonts.ready')
set_browser_zoom(worker,page,zoom)
trigger=page.get_by_role('button',name='Create API Key',exact=True);trigger.focus();trigger.press('Enter')
dialog=page.locator('dialog:modal');dialog.wait_for()
page.wait_for_function("document.querySelector('dialog:modal [data-dialog-initial]')===document.activeElement")
focus=[]
for key in ['Tab']*10+['Shift+Tab']*10:
page.keyboard.press(key);focus.append(page.evaluate("({inside:document.querySelector('dialog:modal').contains(document.activeElement),tag:document.activeElement.tagName,id:document.activeElement.id,documentHasFocus:document.hasFocus()})"))
assert all(s['inside'] or not s['documentHasFocus'] for s in focus)
page.locator('#outside').evaluate('(e)=>e.focus()');assert page.evaluate("document.querySelector('dialog:modal').contains(document.activeElement)")
page.get_by_role('button',name='Save',exact=True).click();dialog.get_by_role('alert').wait_for()
assert not dialog.get_by_role('alert').inner_text().startswith('mxgw_')
page.screenshot(path=str(OUT/f'create-{width}-zoom{zoom}.png'),full_page=False)
results.append({'width':page.evaluate('innerWidth'),'dpr':page.evaluate('devicePixelRatio'),'scroll':page.evaluate('document.documentElement.scrollWidth'),'zoom':zoom,'nativeModal':True,'outsideFocusBlocked':True,'focusSamples':focus,'validationInsideDialog':True})
page.keyboard.press('Escape');page.wait_for_function("!document.querySelector('dialog:modal')")
page.wait_for_function("document.activeElement.textContent.trim()==='Create API Key'")
set_browser_zoom(worker,page,1)
page.set_viewport_size({'width':390,'height':844})
trigger=page.locator('#slow-trigger');trigger.click();page.locator('dialog:modal').wait_for()
page.get_by_role('button',name='Confirm',exact=True).click()
page.keyboard.press('Escape')
page.wait_for_timeout(200);assert page.locator('dialog:modal').count()==1
assert page.locator('#counts').inner_text()=='Synthetic confirms: 1'
page.wait_for_function("!document.querySelector('dialog:modal')")
page.wait_for_function("document.activeElement.id==='slow-trigger'")
# CSS delivery parity independently of assembly version.
href=next(h for h in page.locator('link[rel=stylesheet]').evaluate_all('(es)=>es.map(e=>e.href)') if h.endswith('/css/theme.css'))
csssha=hashlib.sha256(page.request.get(href).body()).hexdigest();assert csssha=='7a6da7aefcf036f971f18816e3ceb129f1abb4a39f6db33d449420b814cfb4a6'
record={'cases':results,'slowBusyEscapeSingleDispatch':True,'servedThemeCssSha256':csssha,'errors':errors}
(OUT/'results.json').write_text(json.dumps(record,indent=2));print(json.dumps({'cases':len(results),'errors':errors,'outsideTabSamples':[r for case in results for r in case['focusSamples'] if not r['inside']]},indent=2))
@@ -0,0 +1,37 @@
"""Focused native lifecycle checks; no broad screenshot iteration."""
import asyncio,json
from pathlib import Path
from playwright.async_api import async_playwright
ROOT=Path(__file__).resolve().parent;BASE=json.load(open('/tmp/mx-ui-canary-state.json'))['origin']
async def main():
async with async_playwright() as p:
browser=await p.chromium.launch(channel='chromium',headless=True);page=await browser.new_page()
release=asyncio.Event();requested=asyncio.Event()
async def hold(route):
requested.set();await release.wait();await route.continue_()
await page.route('**/js/dashboard-dialog.js',hold)
await page.goto(BASE);await page.wait_for_selector('html[data-mx-ready="true"]')
await page.get_by_role('button',name='Create API Key',exact=True).click();await asyncio.wait_for(requested.wait(),10)
dialog=page.locator('dialog.api-key-create-modal');assert await dialog.count()==1
assert not await dialog.is_visible(), 'Requested native dialog must stay hidden until showModal'
# Close the parent while its import is pending. Completion must not resurrect it.
await page.locator('#outside').focus()
# Its visible trigger remains usable while native activation has not happened.
await page.evaluate("document.querySelector('dialog.api-key-create-modal button[aria-label=\"Close create API key\"]').click()")
await page.wait_for_function("!document.querySelector('dialog.api-key-create-modal')")
release.set();await page.wait_for_timeout(300)
assert await page.locator('dialog:modal').count()==0
await page.unroute('**/js/dashboard-dialog.js',hold)
# Reopen after disposal, then make the connected trigger unusable before cancel.
trigger=page.get_by_role('button',name='Create API Key',exact=True)
await trigger.click();await page.locator('dialog:modal').wait_for()
await trigger.evaluate('(e)=>e.disabled=true')
await page.keyboard.press('Escape');await page.wait_for_function("!document.querySelector('dialog:modal')")
await page.wait_for_function("document.activeElement.tagName==='H1'")
assert await page.locator('h1').get_attribute('tabindex')=='-1'
await page.locator('#outside').focus();assert await page.locator('h1').get_attribute('tabindex') is None
# Idempotent listener cleanup permits another instance after cancelled/disposed import.
await page.locator('#slow-trigger').click();await page.locator('dialog:modal').wait_for();await page.keyboard.press('Escape');await page.wait_for_function("!document.querySelector('dialog:modal')")
(ROOT/'evidence/mx02/lifecycle.json').write_text(json.dumps({'pendingImportHidden':True,'disposeBeforeImportCompletionNoResurrection':True,'reopenAfterDisposal':True,'connectedDisabledTriggerFallsBackToHeading':True,'headingTabindexRemovedOnBlur':True,'subsequentInstanceOpensAndCancels':True},indent=2))
await browser.close();print('Focused native lifecycle checks passed')
asyncio.run(main())
@@ -0,0 +1,66 @@
# MX native-dialog pilot
Implemented and verified locally 2026-11-13 on codex/scada-ui-consistency.
No deployment, COM/worker interaction, real API key creation or session operation.
Shared Theme is exact 1.0.1, with official-source/package and served-CSS hash proof
in `evidence/mx02/theme-package.json`. Secrets packages remain 0.6.2 pending the
separately reviewed shared Secrets release. Blue/IBM Plex/shared semantic inks
retain the family contract. Native dialog geometry is local pilot code, not a
new shared package or an extraction decision.
The app-local NativeDialog adapter is used by existing ConfirmDialog callers and
the API-key create form. Native showModal supplies top-layer presentation and
background inertness. Native Tab behavior is preserved. Confirmations initially
focus Cancel; the long create form starts on visible Key ID. Native cancel is
prevented synchronously, then delegated to current-generation safe parent cancel
only while idle. Busy and dispatch ownership remain in existing pages. JS receives
DOM references, busy/generation metadata and cancel callback only: no form fields,
key value, operation or token.
Lifecycle import/open/close/dispose is serialized. Changed target generations and
disposal reject obsolete completion; interop listeners/module and DotNet reference
are released. Client MutationObserver cleanup covers removed nodes when a lost
circuit cannot call JS disposal. A second active native modal is refused. Focus
returns to a usable connected trigger; otherwise the page heading gets temporary
programmatic focus, with tabindex removed on blur. A newly claimed outside focus
is respected. Native backdrop is the only dimming layer.
## Observed checks
- Baseline 341 dashboard tests passed. Two semantic tests failed on the old overlay,
then 10 focused tests passed; 343 dashboard tests pass with every 341 prior test
identity retained, no failures/skips. Framework HtmlRenderer is preserved; bUnit
was not added. Final validation-markup adjustment has 10 focused tests plus actual
browser rectangle verification. Full gateway tests remain for chapter acceptance.
- Actual components and existing create form run with inert snapshots and fake
management/auth services in an OS-port loopback host. No production providers.
Fixture source is `host/`; build outputs are task-local /tmp artifacts.
- First batched browser pass and one confirmation cover 1440,1024, 390 and real 200%
zoom (720 CSS px/DPR 2). Initial focus, native modal/background inertness, keyboard
scope, Escape/cancel, focus return and exactly one delayed synthetic confirm while
Escape is pressed pass. No browser page errors; no document overflow. Served
Theme CSS equals the published exact package.
- The correction batch removed legacy forced display on the native create class,
supplied header/body/footer padding previously inherited from Bootstrap's old
outer modal variables, and chose the visible initial form field.
- A focused functional regression subsequently reproduced an offscreen validation
alert in the independently scrolling form body. Fixed non-sensitive feedback now
stays between the header and bounded flex body. Red and green rectangle evidence
at 1440/390/200% prove visibility; 180 Tab samples keep application focus inside the
modal. Browser chrome samples are explicitly document.hasFocus=false.
- Focused lifecycle checks prove requested dialog hidden during deferred import,
disposal before completion without resurrection, reopen, connected-disabled
trigger fallback, heading tabindex cleanup and subsequent-instance cancellation.
A native dialog may Tab to browser chrome; this is permitted by
[W3C H102](https://www.w3.org/WAI/WCAG22/Techniques/html/H102). Checks distinguish
that document-unfocused state from focus reaching an underlying application
control. This avoids adding a custom Tab trap contrary to the native pilot plan.
Independent source review is retained in the umbrella's
`components/ui-theme/validation/mx-ui/native-dialog-review.md`; the subsequent
validation visibility fix is supported by focused browser evidence. One-time-key
handling, policies, request construction and service interfaces are unchanged.
Human screen-reader listening and additional browser engines are not claimed.
OEE-02 may now implement the second native pilot; shared extraction waits for G2.
@@ -0,0 +1,26 @@
"""Focused validation/focus contract, not an additional visual polish pass."""
import json,sys
from pathlib import Path
from playwright.sync_api import sync_playwright
ROOT=Path(__file__).resolve().parent
sys.path.insert(0,'/Users/dohertj2/.codex/worktrees/scada-ui-consistency/scadaproj/components/ui-theme/validation/theme-1.0.0/canary')
from browser_zoom import zoom_browser,set_browser_zoom
BASE=json.load(open('/tmp/mx-ui-canary-state.json'))['origin'];measurements=[]
with sync_playwright() as p:
with zoom_browser(p) as (ctx,worker):
page=ctx.new_page()
for width,zoom in [(1440,1),(390,1),(1440,2)]:
page.set_viewport_size({'width':width,'height':900});page.goto(BASE);page.wait_for_selector('html[data-mx-ready="true"]');set_browser_zoom(worker,page,zoom)
page.get_by_role('button',name='Create API Key',exact=True).click();page.locator('dialog:modal').wait_for()
page.wait_for_function("document.querySelector('#keyId')===document.activeElement")
initial=page.locator('#keyId').evaluate('(e)=>{const r=e.getBoundingClientRect();return r.top>=0&&r.bottom<=innerHeight}')
samples=[]
for _ in range(60):
page.keyboard.press('Tab');samples.append(page.evaluate("({inside:document.querySelector('dialog:modal').contains(document.activeElement),documentHasFocus:document.hasFocus()})"))
assert all(s['inside'] or not s['documentHasFocus'] for s in samples)
page.get_by_role('button',name='Save',exact=True).click();page.locator('dialog:modal').get_by_role('alert').wait_for()
measure=page.locator('dialog:modal').get_by_role('alert').evaluate('''e=>{const r=e.getBoundingClientRect(),d=e.closest('dialog').getBoundingClientRect();const scroll=e.closest('.modal-body');const s=scroll?.getBoundingClientRect();return {alert:{top:r.top,bottom:r.bottom},dialog:{top:d.top,bottom:d.bottom},body:s?{top:s.top,bottom:s.bottom}:null,visible:r.top>=Math.max(0,d.top,s?.top??0)&&r.bottom<=Math.min(innerHeight,d.bottom,s?.bottom??innerHeight)}}''')
measure.update(width=page.evaluate('innerWidth'),zoom=zoom,initialKeyIdVisible=initial,tabSamples=len(samples),chromeSamples=sum(not s['documentHasFocus'] for s in samples));measurements.append(measure)
page.keyboard.press('Escape');page.wait_for_function("!document.querySelector('dialog:modal')");set_browser_zoom(worker,page,1)
path=ROOT/'evidence/mx02'/sys.argv[1];path.write_text(json.dumps(measurements,indent=2));print(json.dumps(measurements,indent=2))
assert all(m['visible'] and m['initialKeyIdVisible'] for m in measurements),'Validation or initial field outside visible modal viewport'
@@ -51,9 +51,7 @@ else
@if (IsCreateDialogOpen)
{
<div class="modal-backdrop fade show"></div>
<div class="modal fade show api-key-create-modal" role="dialog" aria-modal="true" aria-labelledby="createApiKeyTitle">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<NativeDialog IsOpen="true" IsBusy="@IsBusy" LabelledBy="createApiKeyTitle" Class="api-key-create-modal" OnCancel="CloseCreateDialog">
<div class="modal-content">
@* Master SiteForm pattern: card-wrapped body with stacked
subsections (h6 text-muted border-bottom). Modal chrome
@@ -63,8 +61,12 @@ else
inline at the bottom of the card-body (no modal-footer). *@
<div class="modal-header">
<h2 class="modal-title h5" id="createApiKeyTitle">Create API Key</h2>
<button type="button" class="btn-close" aria-label="Close" @onclick="CloseCreateDialog"></button>
<button type="button" class="btn-close" aria-label="Close create API key" disabled="@IsBusy" @onclick="CloseCreateDialog"></button>
</div>
@if (!LastOperationSucceeded && !string.IsNullOrWhiteSpace(ResultMessage))
{
<p class="alert alert-danger native-dialog-feedback" role="alert">@ResultMessage</p>
}
<div class="modal-body">
<EditForm Model="@CreateModel" OnSubmit="@CreateApiKeyAsync">
<div class="card mb-3">
@@ -72,7 +74,7 @@ else
<h6 class="card-title">Create API Key</h6>
<div class="mb-2">
<label for="keyId" class="form-label small">Key ID</label>
<input id="keyId" class="form-control form-control-sm" @bind="CreateModel.KeyId" @bind:event="oninput" />
<input id="keyId" data-dialog-initial class="form-control form-control-sm" @bind="CreateModel.KeyId" @bind:event="oninput" />
</div>
<div class="mb-3">
<label for="displayName" class="form-label small">Display Name</label>
@@ -148,7 +150,7 @@ else
<div class="mt-3">
<div class="btn-group btn-group-sm" role="group" aria-label="Create API key actions">
<button type="submit" class="btn btn-success" disabled="@IsBusy">Save</button>
<button type="submit" class="btn btn-success" data-dialog-submit disabled="@IsBusy">Save</button>
<button type="button" class="btn btn-outline-secondary" disabled="@IsBusy" @onclick="CloseCreateDialog">Cancel</button>
</div>
</div>
@@ -157,8 +159,7 @@ else
</EditForm>
</div>
</div>
</div>
</div>
</NativeDialog>
}
}
@@ -1,40 +1,25 @@
@if (IsOpen)
{
<div class="modal-backdrop fade show"></div>
<div class="modal fade show" role="dialog" aria-modal="true" aria-labelledby="@TitleId" tabindex="-1" style="display: block;">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title h5" id="@TitleId">@Title</h2>
<button type="button" class="btn-close" aria-label="Close"
disabled="@IsBusy"
@onclick="OnCancel"></button>
</div>
<div class="modal-body">
<p class="mb-0">@Message</p>
</div>
<div class="modal-footer">
<div class="btn-group" role="group" aria-label="Confirm or cancel">
<button type="button" class="btn btn-outline-secondary"
disabled="@IsBusy"
@onclick="OnCancel">
Cancel
</button>
<button type="button" class="btn @ConfirmButtonClass"
disabled="@IsBusy"
@onclick="OnConfirm">
@ConfirmLabel
</button>
</div>
</div>
<NativeDialog IsOpen="@IsOpen" IsBusy="@IsBusy" Target="@((Title, Message))"
LabelledBy="@TitleId" DescribedBy="@MessageId" OnCancel="OnCancel">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title h5" id="@TitleId">@Title</h2>
<button type="button" class="btn-close" aria-label="Close confirmation" disabled="@IsBusy" @onclick="OnCancel"></button>
</div>
<div class="modal-body"><p class="mb-0" id="@MessageId">@Message</p></div>
<div class="modal-footer">
<div class="btn-group" role="group" aria-label="Confirm or cancel">
<button type="button" class="btn btn-outline-secondary" data-dialog-initial disabled="@IsBusy" @onclick="OnCancel">Cancel</button>
<button type="button" class="btn @ConfirmButtonClass" data-dialog-submit disabled="@IsBusy" @onclick="OnConfirm">@ConfirmLabel</button>
</div>
</div>
</div>
}
</NativeDialog>
@code {
private readonly string TitleId = $"confirm-dialog-{Guid.NewGuid():N}";
private string MessageId => $"{TitleId}-message";
[Parameter]
public bool IsOpen { get; set; }
@@ -0,0 +1,123 @@
@using Microsoft.JSInterop
@using Microsoft.Extensions.DependencyInjection
@implements IAsyncDisposable
@inject IServiceProvider Services
<dialog @ref="_element" class="dashboard-native-dialog @Class" aria-labelledby="@LabelledBy"
aria-describedby="@DescribedBy" aria-busy="@(IsBusy ? "true" : "false")" data-busy="@(IsBusy ? "true" : "false")">
@if (IsOpen)
{
@ChildContent
}
</dialog>
@code {
private readonly SemaphoreSlim _lifecycle = new(1, 1);
private ElementReference _element;
private IJSObjectReference? _module;
private DotNetObjectReference<NativeDialog>? _self;
private bool _disposed;
private bool _lastOpen;
private bool _needsOpen;
private bool _cancelPending;
private object? _lastTarget;
private long _generation;
private Task? _disposeTask;
/// <summary>Whether the parent requests an interactive native modal.</summary>
[Parameter] public bool IsOpen { get; set; }
/// <summary>Parent-owned in-flight state; it prevents safe cancellation.</summary>
[Parameter] public bool IsBusy { get; set; }
/// <summary>Identity of the confirmation target, excluding confidential content.</summary>
[Parameter] public object? Target { get; set; }
/// <summary>ID of the visible title.</summary>
[Parameter] public string LabelledBy { get; set; } = string.Empty;
/// <summary>ID of the consequence or descriptive text.</summary>
[Parameter] public string? DescribedBy { get; set; }
/// <summary>Optional local sizing class.</summary>
[Parameter] public string? Class { get; set; }
/// <summary>Parent-owned controls and content; this adapter never submits an operation.</summary>
[Parameter] public RenderFragment? ChildContent { get; set; }
/// <summary>Safe cancellation callback.</summary>
[Parameter] public EventCallback OnCancel { get; set; }
/// <inheritdoc />
protected override void OnParametersSet()
{
if (_lastOpen == IsOpen && Equals(_lastTarget, Target)) return;
_lastOpen = IsOpen;
_lastTarget = Target;
++_generation;
_needsOpen = IsOpen;
_cancelPending = false;
}
/// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await _lifecycle.WaitAsync();
long rejectedGeneration = -1;
bool openedNow = false;
try
{
if (_disposed) return;
long generation = _generation;
if (IsOpen && _module is null)
{
// Resolve before the first await; do not reach through a disposed circuit scope.
IJSRuntime js = Services.GetRequiredService<IJSRuntime>();
_module = await js.InvokeAsync<IJSObjectReference>("import", "./js/dashboard-dialog.js");
}
if (_disposed || generation != _generation) return;
if (_module is null) return;
if (!IsOpen)
{
await _module.InvokeVoidAsync("close", _element);
}
else if (_needsOpen)
{
_needsOpen = false;
_self ??= DotNetObjectReference.Create(this);
bool opened = await _module.InvokeAsync<bool>("open", _element, _self, generation);
openedNow = opened;
if (!opened) rejectedGeneration = generation;
}
if (!openedNow && !_disposed && generation == _generation && IsOpen)
await _module.InvokeVoidAsync("update", _element, generation, IsBusy);
}
catch (JSDisconnectedException) { }
finally { _lifecycle.Release(); }
if (rejectedGeneration == _generation) await RequestCancelAsync(rejectedGeneration);
}
/// <summary>Cancels only the current, idle presentation; invoked by the native cancel event.</summary>
[JSInvokable]
public Task RequestCancelAsync(long generation) => InvokeAsync(async () =>
{
if (_disposed || !IsOpen || IsBusy || _cancelPending || generation != _generation) return;
_cancelPending = true;
try { await OnCancel.InvokeAsync(); }
finally { if (generation == _generation) _cancelPending = false; }
});
/// <inheritdoc />
public ValueTask DisposeAsync() => new(_disposeTask ??= DisposeCoreAsync());
private async Task DisposeCoreAsync()
{
_disposed = true;
++_generation;
await _lifecycle.WaitAsync();
try
{
if (_module is not null)
{
try { await _module.InvokeVoidAsync("close", _element); }
catch (JSDisconnectedException) { }
try { await _module.DisposeAsync(); }
catch (JSDisconnectedException) { }
}
}
finally { _self?.Dispose(); _lifecycle.Release(); }
}
}
@@ -15,7 +15,7 @@
<PackageReference Include="ZB.MOM.WW.Auth.ApiKeys" Version="0.4.1" />
<PackageReference Include="ZB.MOM.WW.Auth.AspNetCore" Version="0.4.1" />
<PackageReference Include="ZB.MOM.WW.Audit" Version="0.1.0" />
<PackageReference Include="ZB.MOM.WW.Theme" Version="0.5.0" />
<PackageReference Include="ZB.MOM.WW.Theme" Version="1.0.1" />
<PackageReference Include="ZB.MOM.WW.Configuration" Version="0.1.0" />
<PackageReference Include="ZB.MOM.WW.Health" Version="0.3.0" />
<PackageReference Include="ZB.MOM.WW.Telemetry" Version="0.3.1" />
@@ -270,7 +270,7 @@ code {
white-space: normal;
font-family: var(--mono);
}
.api-key-create-modal { display: block; }
/* Native dialog owns open/closed display; never force a closed dialog visible. */
.api-key-create-modal .modal-body {
max-height: min(70vh, 44rem);
overflow-y: auto;
@@ -522,3 +522,28 @@ code {
@media (max-width: 960px) {
.browse-layout { grid-template-columns: minmax(0, 1fr); }
}
/* Local native-modal pilot: canonical palette/chrome, one native backdrop. */
.dashboard-native-dialog {
padding: 0; border: 1px solid var(--rule-strong); border-radius: 8px;
width: min(32rem, calc(100% - 2rem)); max-width: calc(100% - 2rem);
max-height: calc(100dvh - 2rem); overflow: auto;
background: var(--card); color: var(--ink);
}
.dashboard-native-dialog::backdrop { background: rgb(0 0 0 / .45); }
.dashboard-native-dialog.api-key-create-modal { width: min(70rem, calc(100% - 2rem)); }
.dashboard-native-dialog .modal-content { border: 0; }
.dashboard-native-dialog .modal-header {
display: flex; align-items: center; justify-content: space-between; gap: 1rem;
padding: 1rem; border-bottom: 1px solid var(--rule);
}
.dashboard-native-dialog .modal-header .btn-close { margin: 0; padding: .5rem; flex: none; }
.dashboard-native-dialog .modal-body { padding: 1rem; }
.dashboard-native-dialog .modal-footer { padding: .75rem 1rem; border-top: 1px solid var(--rule); gap: .5rem; }
/* Keep user-triggered validation visible while only the long form body scrolls. */
.dashboard-native-dialog .modal-content { max-height: calc(100dvh - 2rem - 2px); }
.dashboard-native-dialog .modal-header, .dashboard-native-dialog .modal-footer { flex-shrink: 0; }
.dashboard-native-dialog.api-key-create-modal .modal-body { min-height: 0; max-height: none; overflow-y: auto; }
.dashboard-native-dialog .native-dialog-feedback { margin: 0; border-radius: 0; flex-shrink: 0; }
@@ -0,0 +1,79 @@
// Local native-dialog pilot. No operation, form value or token crosses this adapter.
const states = new WeakMap();
let active;
const usable = node => {
if (!node?.isConnected || node.matches(':disabled') || node.getAttribute('aria-disabled') === 'true' || !node.getClientRects().length) return false;
for (let ancestor = node; ancestor; ancestor = ancestor.parentElement) {
const style = getComputedStyle(ancestor);
if (ancestor.hidden || ancestor.inert || style.display === 'none' || ['hidden', 'collapse'].includes(style.visibility)) return false;
}
return true;
};
export function open(dialog, dotnet, generation) {
close(dialog);
if (!dialog?.isConnected || (active?.isConnected && active.open && active !== dialog) || document.querySelector('dialog:modal')) return false;
const state = { trigger: document.activeElement, generation, pending: false, busy: dialog.dataset.busy === 'true' };
state.cancel = event => {
// Native cancel must be prevented synchronously, before any circuit round trip.
event.preventDefault();
if (state.busy || state.pending || dialog.dataset.busy === 'true') return;
state.pending = true;
dotnet.invokeMethodAsync('RequestCancelAsync', generation).catch(() => {});
};
state.operation = event => {
if (event.type === 'submit' || event.target.closest('[data-dialog-submit]')) state.pending = true;
};
states.set(dialog, state);
dialog.addEventListener('cancel', state.cancel);
dialog.addEventListener('click', state.operation);
dialog.addEventListener('submit', state.operation);
// Client-owned cleanup also runs when a disconnected circuit removes the node
// before server disposal can invoke interop.
state.observer = new MutationObserver(() => {
if (!dialog.isConnected) close(dialog);
});
state.observer.observe(document.body, { childList: true, subtree: true });
try {
dialog.showModal();
active = dialog;
dialog.querySelector('[data-dialog-initial]')?.focus({ preventScroll: true });
return true;
} catch (error) {
close(dialog);
throw error;
}
}
export function update(dialog, generation, busy) {
const state = states.get(dialog);
if (!state || state.generation !== generation) return;
state.busy = busy;
state.pending = false;
}
export function close(dialog) {
const state = states.get(dialog);
if (!state) return;
states.delete(dialog);
state.observer.disconnect();
dialog.removeEventListener('cancel', state.cancel);
dialog.removeEventListener('click', state.operation);
dialog.removeEventListener('submit', state.operation);
if (dialog.open) dialog.close();
if (active === dialog) active = null;
requestAnimationFrame(() => {
if (active?.open || document.querySelector('dialog:modal')) return;
const current = document.activeElement;
if (usable(current) && ![state.trigger, document.body, document.documentElement].includes(current) && !dialog.contains(current)) return;
const fallback = document.querySelector('main h1');
for (const target of [state.trigger, fallback]) {
if (!usable(target)) continue;
const oldTabindex = target.getAttribute('tabindex');
if (target === fallback && oldTabindex === null) target.tabIndex = -1;
target.focus({ preventScroll: true });
if (target === document.activeElement) {
if (target === fallback && oldTabindex === null)
target.addEventListener('blur', () => target.removeAttribute('tabindex'), { once: true });
return;
}
}
});
}
@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Shared;
namespace ZB.MOM.WW.MxGateway.Tests.Dashboard;
/// <summary>Semantic contracts only; actual modal/focus behavior is browser-verified.</summary>
public sealed class ConfirmDialogRenderTests
{
/// <summary>Confirmations name their native modal and expose complete escaped consequences.</summary>
[Fact]
public async Task RequestedConfirmation_RendersNamedNativeDialogAndSafeCancel()
{
string html = await RenderAsync(new()
{
[nameof(ConfirmDialog.IsOpen)] = true,
[nameof(ConfirmDialog.Title)] = "Close session example",
[nameof(ConfirmDialog.Message)] = "Clients disconnect <script>fixture</script>.",
});
Assert.Contains("<dialog", html, StringComparison.Ordinal);
Assert.Contains("aria-labelledby=", html, StringComparison.Ordinal);
Assert.Contains("aria-describedby=", html, StringComparison.Ordinal);
Assert.Contains("Close session example", html, StringComparison.Ordinal);
Assert.Contains("Cancel", html, StringComparison.Ordinal);
Assert.Contains("&lt;script&gt;fixture&lt;/script&gt;", html, StringComparison.Ordinal);
Assert.DoesNotContain("modal-backdrop", html, StringComparison.Ordinal);
}
/// <summary>Busy ownership remains visible and both operation controls remain disabled.</summary>
[Fact]
public async Task BusyConfirmation_ExposesBusyStateAndRetainsDisabledActions()
{
string html = await RenderAsync(new()
{
[nameof(ConfirmDialog.IsOpen)] = true,
[nameof(ConfirmDialog.IsBusy)] = true,
});
Assert.Contains("aria-busy=\"true\"", html, StringComparison.Ordinal);
Assert.Equal(3, html.Split(" disabled", StringSplitOptions.None).Length - 1);
}
private static async Task<string> RenderAsync(Dictionary<string, object?> parameters)
{
ServiceCollection services = new();
services.AddLogging();
await using ServiceProvider provider = services.BuildServiceProvider();
await using HtmlRenderer renderer = new(provider, provider.GetRequiredService<ILoggerFactory>());
return await renderer.Dispatcher.InvokeAsync(async () =>
(await renderer.RenderComponentAsync<ConfirmDialog>(ParameterView.FromDictionary(parameters))).ToHtmlString());
}
}