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 <html> 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.
This commit is contained in:
Maurice
2026-11-09 08:32:24 +01:00
parent fede671f3b
commit d9baaa8957
3 changed files with 31 additions and 0 deletions
+20
View File
@@ -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"] {
+7
View File
@@ -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", () => {
+4
View File
@@ -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.