fix(ui/treeview): union sessionStorage keys instead of overwriting
The previous fix tried to defer page-side RevealNode to the second render so TreeView's async sessionStorage load could finish first. In practice Blazor Server didn't always fire a second OnAfterRenderAsync on the page after the deep-link load, so the reveal never ran. Real fix: change TreeView's storage-load to UNION the restored keys with whatever's already in _expandedKeys, instead of REPLACING. That way the page can call RevealNode whenever it wants and the storage restore can't clobber the reveal regardless of completion order. The page-side guard simplifies back to a one-shot reveal on first render. Semantic note: if a deep-link reveal expands an ancestor that the user had previously collapsed, the deep link wins. Intentional — the URL expresses the navigation intent.
This commit is contained in:
@@ -181,9 +181,7 @@
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
// Wait until second render so TreeView has finished restoring its sessionStorage
|
||||
// expansion state; otherwise that restore races with RevealNode and overwrites it.
|
||||
if (!_revealApplied && !firstRender && TemplateIdParam > 0 && _tree != null)
|
||||
if (!_revealApplied && TemplateIdParam > 0 && _tree != null)
|
||||
{
|
||||
_revealApplied = true;
|
||||
await _tree.RevealNode($"t:{TemplateIdParam}", select: true);
|
||||
|
||||
Reference in New Issue
Block a user