Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(native): a long press in the app selects no text and opens no callout

Mauriced9baaa89579a
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 <html> 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.