fix(centralui): DialogHost cleanup only on open->closed transition + drop trailing class space (T33a review)
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
@onkeydown="OnKeyDown">
|
@onkeydown="OnKeyDown">
|
||||||
<div class="modal-dialog modal-dialog-centered @state.Size" role="document">
|
<div class="modal-dialog modal-dialog-centered@(state.Size is null ? "" : $" {state.Size}")" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">@state.Title</h5>
|
<h5 class="modal-title">@state.Title</h5>
|
||||||
@@ -125,14 +125,20 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_focusedForState = null;
|
// Only clean up on the actual open→closed transition. Skipping when
|
||||||
try { await JS.InvokeVoidAsync("document.body.classList.remove", "modal-open"); }
|
// _focusedForState is already null avoids spurious JS interop on
|
||||||
catch { /* prerender: no JS — ignore */ }
|
// the initial render and every steady-state no-dialog render.
|
||||||
|
if (_focusedForState is not null)
|
||||||
|
{
|
||||||
|
_focusedForState = null;
|
||||||
|
try { await JS.InvokeVoidAsync("document.body.classList.remove", "modal-open"); }
|
||||||
|
catch { /* prerender: no JS — ignore */ }
|
||||||
|
|
||||||
// Return focus to whatever element triggered the dialog so keyboard
|
// Return focus to whatever element triggered the dialog so keyboard
|
||||||
// users are not dumped at the top of the document on close.
|
// users are not dumped at the top of the document on close.
|
||||||
try { await JS.InvokeVoidAsync("sbDialog.restoreActiveElement"); }
|
try { await JS.InvokeVoidAsync("sbDialog.restoreActiveElement"); }
|
||||||
catch { /* prerender: no JS — ignore */ }
|
catch { /* prerender: no JS — ignore */ }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user