mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
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:
@@ -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", () => {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user