Backoffice: CTRL+Click to open in a new tab should work on Linux (closes #21009) (#21027)

* fix: uses 'href' as property instead of attribute

* build: runs on PR to release branches

* Content references: Avoid requesting references for content that is not yet persisted server side (#21035)

* Avoid requesting references for content that is not yet persisted server side.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor to use condition

* revert

* danish translations

* da translation

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>

* fix: CTRL+Click now opens links in new tab on Linux

The router's anchor click handler incorrectly assumed non-Windows
platforms use Meta (⌘) key for "open in new tab". This broke
CTRL+Click on Linux, which uses CTRL like Windows.

Changed detection from "is Windows" to "is Mac" so Linux correctly
uses CTRL+Click while Mac continues to use Meta+Click.

Also replaced deprecated navigator.platform with navigator.userAgent.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Jacob Overgaard
2025-12-03 16:03:18 +01:00
committed by GitHub
parent c35fcf181b
commit 84fecd3521
3 changed files with 10 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ on:
push:
branches:
- main
- release/*
- v*/dev
- v*/main
paths:
@@ -15,6 +16,7 @@ on:
types: [opened, synchronize, reopened, closed]
branches:
- main
- release/*
- v*/dev
- v*/main
workflow_dispatch:

View File

@@ -1,6 +1,5 @@
import { UMB_BACKOFFICE_CONTEXT } from '../backoffice.context.js';
import type { UmbBackofficeContext } from '../backoffice.context.js';
import type { CSSResultGroup } from '@umbraco-cms/backoffice/external/lit';
import { css, customElement, html, ifDefined, repeat, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { ManifestSection } from '@umbraco-cms/backoffice/section';
@@ -113,15 +112,13 @@ export class UmbBackofficeHeaderSectionsElement extends UmbLitElement {
const label = this.localize.string(manifest?.meta.label || manifest?.name);
return html`<uui-tab
data-mark="section-link:${manifest.alias}"
href=${this.#getSectionPath(manifest)}
.href=${this.#getSectionPath(manifest)}
label=${ifDefined(label)}
?active=${this._currentSectionAlias === manifest.alias}
@click=${(event: PointerEvent) => this.#onSectionClick(event, manifest)}
>${label}</uui-tab
>`;
@click=${(event: PointerEvent) => this.#onSectionClick(event, manifest)}></uui-tab>`;
}
static override styles: CSSResultGroup = [
static override readonly styles = [
css`
:host {
display: contents;

View File

@@ -3,11 +3,13 @@
* that has a relative HREF, uses the history API instead.
*/
export function ensureAnchorHistory() {
const isWindows = navigator.platform.toUpperCase().indexOf('WIN') !== -1;
const isMac = /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
window.addEventListener('click', (e: MouseEvent) => {
// If we try to open link in a new tab, then we want to skip skip:
if ((isWindows && e.ctrlKey) || (!isWindows && e.metaKey)) return;
// If we try to open link in a new tab, we want to skip:
// - Mac uses Meta (⌘) + Click
// - Windows and Linux use Ctrl + Click
if ((isMac && e.metaKey) || (!isMac && e.ctrlKey)) return;
// Find the target by using the composed path to get the element through the shadow boundaries.
// Support both HTML anchor tags and SVG anchor tags