Skip to content

Keep the flag editor's browser tab title after modals close - #75

Merged
readingdancer merged 2 commits into
developfrom
fix/editor-tab-title
Nov 23, 2026
Merged

readingdancer merged 2 commits into
developfrom
fix/editor-tab-title

Conversation

@readingdancer

@readingdancer readingdancer commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

The flag workspace's browser tab title should be {flag name} | {view label} | Umbraco. It broke two ways, both in Umbraco's view-context code (identical in 17.8.2, 18.3.2, 19.0.0-rc1):

  1. After a modal closes (Reset's confirm, the discard-changes modal) the title became Settings | Umbraco. The modal is hosted on the workspace context, so its view context parents to the section's view, deactivates ours while open, and on close activates that parent. Nothing re-activates the routed workspace view. Our old second setTitle(name) was a no-op (setTitle returns early when unchanged, and only writes while active).
  2. … | About while Settings shows. _internal_addChild activates every child view as it registers, without checking it is the routed one, so the last registered view writes the title.

Fix: after those events, activate the view context of the tab the URL shows, which rewrites the title.

  • routed-view.ts: pure routedViewAlias(views, path) (segment after /view/ matched to meta.pathname; none means first view; unknown or no views means null).
  • flag-editor.element.ts: consumes UMB_WORKSPACE_EDITOR_CONTEXT from the <umb-workspace-editor> element (it is provided there, below our element) and hands it to the workspace context.
  • flag-workspace.context.ts: setEditorContext() observes the editor's views; #reassertTitle() finds the routed view and calls its _internal_activate() (guarded by typeof). Removed the useless second setTitle.
reset()           -> finally after umbConfirmModal -> #reassertTitle()
#onWillNavigate   -> catch (stay on flag)          -> #reassertTitle()
load()            -> finally                       -> #reassertTitle()
setEditorContext / editor.views change             -> #reassertTitle()
#reassertTitle -> routedViewAlias(tabs, location.pathname) -> tab._internal_activate()

Evidence

  • Helper unit tests: before, routed-view.ts did not exist (no tests for it); after, 6 new tests pass (empty path, view/settings, view/about, unknown, no views, encoded flag name containing /view/).
  • Client npm test / npx tsc --noEmit -p . / npm run build:
    • 17.8.2: 124 pass, tsc clean, build ok
    • 18.3.2: 124 pass, tsc clean, build ok
    • 19.0.0-rc1: 124 pass, tsc clean, build ok
  • dotnet build Umbricians.FeatureFlags.slnx -c Release -p:UmbracoMajor=17: 0 warnings, 0 errors.
    Browser check (Umbraco 17.8.2, 18.3.2 and 19.0.0-rc1; demo with its extra "About" view; document.title read after each step):
Step 17 18 19
Full load, no view in the URL: Checkout.ExpressPay | Settings | Umbraco ✅ ✅ ✅
Full load on /view/settings: Settings, not About ✅ ✅ ✅
Full load on /view/about: About ✅ ✅ ✅
Switching tabs: Definition, About, Settings ✅ ✅ ✅
After Save ✅ ✅ ✅
Reset, cancelled / confirmed: stays … | Settings | Umbraco (was Settings | Umbraco) ✅ ✅ ✅
Unsaved change, click away, discard modal, Stay: title kept ✅ ✅ ✅
…then Discard changes: leaves to the list (Feature Flags | Flags | Umbraco) ✅ ✅ ✅
No console errors from the package ✅ ✅ ✅

The first version only fixed in-app navigation. On a full page load the title still read "About": a document.title setter trace showed each tab's view activating as it registered, after our reassert. 5ca64e9 reasserts once more two animation frames later, which fixed it on all three.

Merge Danger

Door: two-way

Blast Radius: Cosmetic

Uses Umbraco's internal UmbViewController._internal_activate() (no public API can reactivate the routed view). The call is guarded with typeof ... === "function", so if Umbraco removes it the title just reverts to Umbraco's own behaviour.

Upstream issue draft

Title: Document title falls back to the parent view's after a modal closes; every child view activates on registration

When a modal is opened with umbOpenModal(host, ...) / umbConfirmModal(host, ...) from a workspace context, the modal's view context finds its parent from the host's parent element (skipping the host) and so parents to the section's view rather than the routed workspace view. While open it deactivates the workspace view; on close destroy() calls #requestActivateParent(), which activates the section view. The tab title becomes Settings | Umbraco and nothing re-activates the workspace view. setTitle() cannot fix it: it returns early when the title is unchanged and only writes while active.

Separately, UmbViewController._internal_addChild calls child._internal_activate() whenever the parent is active, without checking the child is the routed view. With several workspace views (e.g. a package adds an extra one), every view activates and the last registered writes the title (… | About while the first view is showing).

Expected: after a modal closes, the previously active view is re-activated; and only the routed view activates.

Seen in 17.8.2, 18.3.2, 19.0.0-rc1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WAQdHxWd7ft8XjqRAeyGB6

readingdancer and others added 2 commits November 23, 2026 01:12
Umbraco leaves the section's title (Settings | Umbraco) after a modal closes
and lets the last-registered tab set the title. Re-activate the routed tab's
view after Reset's confirm, a cancelled discard, and each load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WAQdHxWd7ft8XjqRAeyGB6
On a full page load the tabs' views register and activate after the views
list arrives and after the flag loads, so the last one registered (the demo's
About) still won. Reassert once more two frames later. Checked in a browser on
Umbraco 17, 18 and 19.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WAQdHxWd7ft8XjqRAeyGB6
@readingdancer
readingdancer marked this pull request as ready for review November 23, 2026 06:22
@readingdancer
readingdancer merged commit ed666c1 into develop Nov 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant