From d9baaa89579abd0b39c44e483316340a657d08f0 Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 9 Nov 2026 08:32:24 +0100 Subject: [PATCH] fix(native): a long press in the app selects no text and opens no callout In the iOS and Android app a long press on a label, card or image started a text selection, the magnifier or a "save image" menu, the clearest sign of a web page in a frame. startNativeApp marks with data-native-app, and index.css then turns selection and the callout off for the UI. Inputs, textareas, selects and editors stay selectable so typing, pasting and the caret work; text worth copying opts in with .trek-selectable. A browser keeps its default. --- client/src/index.css | 20 ++++++++++++++++++++ client/src/native/nativeApp.test.ts | 7 +++++++ client/src/native/nativeApp.ts | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/client/src/index.css b/client/src/index.css index 7bea87652..9cbc91073 100644 --- a/client/src/index.css +++ b/client/src/index.css @@ -391,6 +391,26 @@ html, body { -webkit-tap-highlight-color: transparent; } +/* Inside the iOS and Android app (native/nativeApp.ts sets the attribute): a long + press on a label, card or image does nothing, as in a native app, instead of + starting a text selection, a magnifier or a "save image" callout. What the user + types into stays selectable, or editing, pasting and moving the caret would break; + text worth copying opts in with .trek-selectable. A browser keeps its default. */ +html[data-native-app] body { + -webkit-user-select: none; + user-select: none; + -webkit-touch-callout: none; +} +html[data-native-app] :is(input, textarea, select, [contenteditable]:not([contenteditable='false']), .trek-selectable), +html[data-native-app] :is([contenteditable]:not([contenteditable='false']), .trek-selectable) * { + -webkit-user-select: text; + user-select: text; + -webkit-touch-callout: default; +} +html[data-native-app] img { + -webkit-user-drag: none; +} + /* Tabular-nums global für Time/Date/Currency/Counter */ time, .tabular-nums, [data-tabular], input[type="number"], input[type="time"], input[type="date"], input[type="datetime-local"] { diff --git a/client/src/native/nativeApp.test.ts b/client/src/native/nativeApp.test.ts index be5d7f446..f847a79d7 100644 --- a/client/src/native/nativeApp.test.ts +++ b/client/src/native/nativeApp.test.ts @@ -43,6 +43,7 @@ beforeEach(() => { vi.mocked(isEffectivelyOffline).mockReturnValue(false); vi.mocked(keepOfflineShellFresh).mockResolvedValue(); document.documentElement.classList.remove('dark'); + document.documentElement.removeAttribute('data-native-app'); }); afterEach(() => { @@ -55,6 +56,12 @@ describe('startNativeApp', () => { startNativeApp(); expect(App.addListener).not.toHaveBeenCalled(); expect(StatusBar.setStyle).not.toHaveBeenCalled(); + expect(document.documentElement.hasAttribute('data-native-app')).toBe(false); + }); + + it('marks so a long press selects no text in the app', () => { + startNativeApp(); + expect(document.documentElement.hasAttribute('data-native-app')).toBe(true); }); it("Android's back gesture closes an open sheet before it leaves the page", () => { diff --git a/client/src/native/nativeApp.ts b/client/src/native/nativeApp.ts index d29c12fbd..48084eda8 100644 --- a/client/src/native/nativeApp.ts +++ b/client/src/native/nativeApp.ts @@ -25,6 +25,10 @@ const OFFLINE_SHELL_DELAY_MS = 15_000; export function startNativeApp(): void { if (!isNativeApp()) return; + // Marks the app for index.css: no text selection or long-press callout on the + // UI itself, as in any native app. Fields stay selectable there. + document.documentElement.setAttribute('data-native-app', ''); + followThemeInStatusBar(); // What this binary can do, and whether this server's UI needs a newer one.