V16: Document shows blank page when clicking an active link #19553
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #19522
This seems to only happen when you are on a variant document or a document with tabs, because the first tab is a redirect target. But if the first tab for some reason is not available, which can happen if you click an already active link where the workspace views and tabs are added lazily, then the redirect does not know what to do and you lose the whole workspace editor.
The fix seems to be to mirror what workspace views themselves do, which is to "fake" the first workspace view onto the empty url (
path: ''
) and show the component there. The caveat is that the browser url does not reflect quite where you are, but the end effect is that the browser will show you what you expect to see anyway. Additionally, you can still click on the default tab of the document workspace and get its unique url and that will still work.The difference is that now, when you click on the active tree item, the URL will be "reset" but no redirects will take place, so you will stay. Then eventually the document workspace editor will come through for you and show you first the correct workspace view, then later the expected tab.
How to test
Test with tabs as well:
Sequence
Copilot's Random Thoughts
This pull request refines routing behavior in the
UmbContentWorkspaceViewEditElement
andUmbWorkspaceEditorElement
classes to improve handling of default and fallback routes. Additionally, it enhances the logic for determining active tabs in the content editor. Below is a breakdown of the most significant changes grouped by theme.Routing Improvements:
UmbContentWorkspaceViewEditElement
: Added a new route that duplicates the first route and uses it for empty path scenarios, ensuring proper default routing behavior. Removed redundantpathMatch
andredirectTo
properties.UmbWorkspaceEditorElement
: Introduced a catch-all route (**
) to handle unmatched paths and fallback scenarios gracefully. This ensures users see a "Not Found" page when no other routes match.Tab Activation Logic:
UmbContentWorkspaceViewEditElement
: Updated the logic to mark tabs as active when the router path matches either the root path or an empty path. This adjustment improves the user experience by correctly displaying the active state for tabs in specific routing scenarios.