Skip to content

feat(uve): Fix same-page navigation handling with anchors with id#35326

Merged
KevinDavilaDotCMS merged 3 commits intomainfrom
35324-uve---anchor-links-with-internal-ids-incorrectly-handled-as-external-routes-in-vtl-pages
Apr 15, 2026
Merged

feat(uve): Fix same-page navigation handling with anchors with id#35326
KevinDavilaDotCMS merged 3 commits intomainfrom
35324-uve---anchor-links-with-internal-ids-incorrectly-handled-as-external-routes-in-vtl-pages

Conversation

@KevinDavilaDotCMS
Copy link
Copy Markdown
Member

@KevinDavilaDotCMS KevinDavilaDotCMS commented Apr 15, 2026

  • Added utility to determine if a URL change is a same-page navigation (hash-only or query-only).
  • Updated to prevent triggering page load for same-page navigations.
  • Enhanced tests in to cover various same-page navigation scenarios.
  • Modified to utilize the new utility for navigation updates.
  • Updated to exclude hash-only links from triggering navigation actions.

This change improves user experience by preventing unnecessary page reloads during internal navigation events.

2026-04-15.10-08-42.mov

This PR fixes: #35324

This PR fixes: #35324

- Added  utility to determine if a URL change is a same-page navigation (hash-only or query-only).
- Updated  to prevent triggering page load for same-page navigations.
- Enhanced tests in  to cover various same-page navigation scenarios.
- Modified  to utilize the new utility for navigation updates.
- Updated  to exclude hash-only links from triggering navigation actions.

This change improves user experience by preventing unnecessary page reloads during internal navigation events.
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 15, 2026

Claude finished @KevinDavilaDotCMS's task in 4m 25s —— View job


PR Review

  • Gather context and read changed files
  • Review utility functions and logic
  • Review service and component changes
  • Review tests
  • Post final review

Three issues worth flagging:


1. setEditorState(EDITOR_STATE.IDLE) is now dead code (silent regression)

In dot-uve-actions-handler.service.ts:85-93:

if (isSamePageNavigation(incomingUrl, currentPageUrl)) {
    return;
}

const isSameUrl = compareUrlPaths(currentPageUrl, incomingUrl);
if (isSameUrl) {
    uveStore.setEditorState(EDITOR_STATE.IDLE); // ← never reached
}

Both isSamePageNavigation and compareUrlPaths check pathname === pathname. If isSamePageNavigation returns false (pathnames differ), then compareUrlPaths also returns false — so isSameUrl can never be true after the early return. The setEditorState(EDITOR_STATE.IDLE) call is dead code.

This also introduces a silent behavioral regression: previously, NAVIGATION_UPDATE with the exact same URL (no hash, no query change, e.g. /home/home) called setEditorState(EDITOR_STATE.IDLE). Now it does nothing. If this was load-bearing (e.g., resetting the editor out of a loading state after a same-URL navigation event), it will silently break. There's no test covering this path either. Fix this →


2. Full-path same-page anchor links still cause VTL iframe reloads

The filter in dot-uve-iframe.component.ts:203-205 only excludes bare # links:

const isHashOnly = href?.startsWith('#');
const hasLink = !!href && !isHashOnly;

A link like <a href="/home#section"> has href = '/home#section' (raw attribute), so isHashOnly = false and the click passes through to handleInternalNav. There, isSamePageNavigation returns true and the function returns without calling e.preventDefault(). For a VTL traditional page (content injected via document.write into an about:blank iframe), this causes the iframe to navigate to /home#section, triggering a full page reload inside the iframe and a subsequent onIframeLoad.

The issue title mentions "anchor links with internal IDs" — this case is still broken for full-path anchor links on the same page (/current-page#section when already on /current-page). Fix this →


3. Query-param-only changes silently suppressed for all page types

isSamePageNavigation returns true for /home?tab=2 when current is /home, causing NAVIGATION_UPDATE and handleInternalNav to both no-op. For headless pages where ?tab=2 drives meaningful client-side state, this is fine. But for VTL pages that server-render different content for different query params, silently ignoring a query-param change could mean the editor URL bar and the displayed content go out of sync. Worth confirming this is the intended behavior for VTL query-param navigation.


Comment thread core-web/libs/portlets/edit-ema/portlet/src/lib/utils/index.ts Outdated
- Updated the logic to determine same-page navigation to consider any hash or query changes on the same pathname.
- Modified related tests to reflect the new behavior, ensuring that page loads are not triggered for same-page navigations.
- Improved documentation for the  utility to clarify its functionality.

These changes streamline navigation handling, improving user experience by preventing unnecessary page reloads during internal navigation events.
@KevinDavilaDotCMS KevinDavilaDotCMS added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 673f109 Apr 15, 2026
28 checks passed
@KevinDavilaDotCMS KevinDavilaDotCMS deleted the 35324-uve---anchor-links-with-internal-ids-incorrectly-handled-as-external-routes-in-vtl-pages branch April 15, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Frontend PR changes Angular/TypeScript frontend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

UVE - Anchor links with internal IDs incorrectly handled as external routes in VTL pages

3 participants