Skip to content

fix: keep translation links in the current tab#5158

Open
lilianakatrina684-a11y wants to merge 1 commit intovuejs:mainfrom
lilianakatrina684-a11y:fix-translation-links-same-tab
Open

fix: keep translation links in the current tab#5158
lilianakatrina684-a11y wants to merge 1 commit intovuejs:mainfrom
lilianakatrina684-a11y:fix-translation-links-same-tab

Conversation

@lilianakatrina684-a11y
Copy link
Copy Markdown

Summary

  • let translation links opt out of external-link handling in VPLink
  • use that override for navbar and mobile translation menus so localized docs links stay in the current tab
  • add unit coverage for the new external-link override logic

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the default theme’s link handling so translation menu links can opt out of “external link” behavior (new tab + external icon), keeping localized docs navigation in the current tab.

Changes:

  • Added isLinkExternal() utility to allow explicit override of external-link detection.
  • Extended VPLink with an external?: boolean prop and routed external detection through the new utility.
  • Updated translation menu components to force external=false, and added unit tests for the override logic.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/client/theme-default/support/utils.ts Adds isLinkExternal() helper with optional override behavior.
src/client/theme-default/components/VPLink.vue Introduces external prop and uses isLinkExternal() for external-link behavior.
src/client/theme-default/components/VPNavBarTranslations.vue Forces translation menu links to stay in-tab by passing external=false.
src/client/theme-default/components/VPNavScreenTranslations.vue Forces in-tab navigation for mobile translations and adds hreflang/rel="alternate".
tests/unit/client/theme-default/support/utils.test.ts Adds unit coverage for the new external override logic.
Comments suppressed due to low confidence (1)

src/client/theme-default/components/VPNavBarTranslations.vue:29

  • VPNavBarExtra.vue also renders the translations flyout between 768px and 1279px, but it still uses the default external-link handling (so translation links may continue to open in a new tab at those breakpoints). To fully keep translation links in the current tab across all navbar variants, apply the same external=false override to the translation links in VPNavBarExtra.vue as well.
      <template v-for="locale in localeLinks" :key="locale.link">
        <VPMenuLink
          :item="locale"
          :external="false"
          :lang="locale.lang"
          :hreflang="locale.lang"
          rel="alternate"
          :dir="locale.dir"
        />

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brc-dd
Copy link
Copy Markdown
Member

brc-dd commented Mar 21, 2026

update it here too -

(toggle copilot's low confidence comment for details)

@brc-dd brc-dd force-pushed the main branch 3 times, most recently from 15a0278 to 09af6c7 Compare March 26, 2026 04:26
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.

3 participants