diff --git a/client/android/app/capacitor.build.gradle b/client/android/app/capacitor.build.gradle
index 0fae6fad5..da95d6401 100644
--- a/client/android/app/capacitor.build.gradle
+++ b/client/android/app/capacitor.build.gradle
@@ -9,7 +9,9 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
+ implementation project(':capacitor-action-sheet')
implementation project(':capacitor-app')
+ implementation project(':capacitor-dialog')
implementation project(':capacitor-filesystem')
implementation project(':capacitor-haptics')
implementation project(':capacitor-keyboard')
diff --git a/client/android/capacitor.settings.gradle b/client/android/capacitor.settings.gradle
index 108993d73..47693acf9 100644
--- a/client/android/capacitor.settings.gradle
+++ b/client/android/capacitor.settings.gradle
@@ -2,9 +2,15 @@
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../../node_modules/@capacitor/android/capacitor')
+include ':capacitor-action-sheet'
+project(':capacitor-action-sheet').projectDir = new File('../../node_modules/@capacitor/action-sheet/android')
+
include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../../node_modules/@capacitor/app/android')
+include ':capacitor-dialog'
+project(':capacitor-dialog').projectDir = new File('../../node_modules/@capacitor/dialog/android')
+
include ':capacitor-filesystem'
project(':capacitor-filesystem').projectDir = new File('../../node_modules/@capacitor/filesystem/android')
diff --git a/client/ios/App/App/TrekBridgeViewController.swift b/client/ios/App/App/TrekBridgeViewController.swift
index 88136187a..69e00f541 100644
--- a/client/ios/App/App/TrekBridgeViewController.swift
+++ b/client/ios/App/App/TrekBridgeViewController.swift
@@ -50,6 +50,9 @@ class TrekBridgeViewController: CAPBridgeViewController {
// draws its own (mobile/components/MEdgeBack.tsx, feature "edgeBack"):
// the page follows the finger and an open sheet closes first.
webView?.allowsBackForwardNavigationGestures = false
+ // A long press on a link would lift a preview of the page it points to,
+ // which no native list does; the press means "drag" or nothing here.
+ webView?.allowsLinkPreview = false
}
/// Kept alive here: the content controller holds it, but only for as long as it is registered.
diff --git a/client/ios/App/CapApp-SPM/Package.swift b/client/ios/App/CapApp-SPM/Package.swift
index ac9dff196..31e1a3a87 100644
--- a/client/ios/App/CapApp-SPM/Package.swift
+++ b/client/ios/App/CapApp-SPM/Package.swift
@@ -12,7 +12,9 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "8.5.2"),
+ .package(name: "CapacitorActionSheet", path: "../../../../node_modules/@capacitor/action-sheet"),
.package(name: "CapacitorApp", path: "../../../../node_modules/@capacitor/app"),
+ .package(name: "CapacitorDialog", path: "../../../../node_modules/@capacitor/dialog"),
.package(name: "CapacitorFilesystem", path: "../../../../node_modules/@capacitor/filesystem"),
.package(name: "CapacitorHaptics", path: "../../../../node_modules/@capacitor/haptics"),
.package(name: "CapacitorKeyboard", path: "../../../../node_modules/@capacitor/keyboard"),
@@ -26,7 +28,9 @@ let package = Package(
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm"),
+ .product(name: "CapacitorActionSheet", package: "CapacitorActionSheet"),
.product(name: "CapacitorApp", package: "CapacitorApp"),
+ .product(name: "CapacitorDialog", package: "CapacitorDialog"),
.product(name: "CapacitorFilesystem", package: "CapacitorFilesystem"),
.product(name: "CapacitorHaptics", package: "CapacitorHaptics"),
.product(name: "CapacitorKeyboard", package: "CapacitorKeyboard"),
diff --git a/client/package.json b/client/package.json
index f9e842e1f..e7a9b8de9 100644
--- a/client/package.json
+++ b/client/package.json
@@ -53,9 +53,11 @@
},
"dependencies": {
"@assistant-ui/react": "0.15.25",
+ "@capacitor/action-sheet": "^8.1.1",
"@capacitor/android": "^8.5.0",
"@capacitor/app": "^8.1.1",
"@capacitor/core": "^8.5.0",
+ "@capacitor/dialog": "^8.0.1",
"@capacitor/filesystem": "^8.1.3",
"@capacitor/haptics": "^8.0.2",
"@capacitor/ios": "^8.5.0",
diff --git a/client/postcss.config.js b/client/postcss.config.js
index 2e7af2b7f..81984497d 100644
--- a/client/postcss.config.js
+++ b/client/postcss.config.js
@@ -1,6 +1,8 @@
+import autoprefixer from 'autoprefixer';
+import tailwindcss from 'tailwindcss';
+import touchHover from './postcss/touchHover.js';
+
export default {
- plugins: {
- tailwindcss: {},
- autoprefixer: {},
- },
-}
+ // touchHover last: it guards the :hover rules Tailwind has just written too.
+ plugins: [tailwindcss(), autoprefixer(), touchHover()],
+};
diff --git a/client/postcss/touchHover.js b/client/postcss/touchHover.js
new file mode 100644
index 000000000..782bc64df
--- /dev/null
+++ b/client/postcss/touchHover.js
@@ -0,0 +1,49 @@
+/**
+ * Hover styles only while a pointer drives the UI.
+ *
+ * A finger has no hover, yet WebKit and Chrome apply :hover to whatever was
+ * tapped and keep it there until the next tap lands somewhere else. In the
+ * iOS and Android app that left buttons and rows tinted after every tap, a
+ * tell of a web page that no native app has. The app marks with
+ * data-touch-input while a finger is in use (src/native/touchInput.ts), and
+ * this plugin makes every :hover rule, Tailwind's and our own, wait for that
+ * mark to be gone. A browser never sets it, so nothing changes there, and an
+ * iPad with a trackpad clears it on the first pointer move.
+ *
+ * The condition sits on the hovered element itself, wrapped in :where(), so a
+ * rule keeps its specificity and still wins or loses where it did before. A
+ * :hover after a pseudo-element (::-webkit-slider-thumb:hover) stays as it is:
+ * nothing may follow it there, and a rule with an invalid selector is dropped
+ * whole.
+ */
+
+export const TOUCH_INPUT_ATTR = 'data-touch-input';
+const GUARD = `:where(:root:not([${TOUCH_INPUT_ATTR}]) *)`;
+// :hover itself, not the escaped `hover\:` inside a Tailwind class name, and not :hover-something.
+const HOVER = /(?+~(,]/;
+
+function compoundBefore(selector, index) {
+ let i = index - 1;
+ while (i >= 0 && !COMPOUND_START.test(selector[i])) i--;
+ return selector.slice(i + 1, index);
+}
+
+export function guardHover(selector) {
+ if (selector.includes(GUARD)) return selector;
+ return selector.replace(HOVER, (match, offset) =>
+ compoundBefore(selector, offset).includes('::') ? match : `${match}${GUARD}`
+ );
+}
+
+export default function touchHover() {
+ return {
+ postcssPlugin: 'trek-touch-hover',
+ Rule(rule) {
+ if (!rule.selector.includes(':hover')) return;
+ const next = rule.selectors.map(guardHover);
+ if (next.some((s, i) => s !== rule.selectors[i])) rule.selectors = next;
+ },
+ };
+}
+touchHover.postcss = true;
diff --git a/client/src/components/shared/ConfirmDialog.test.tsx b/client/src/components/shared/ConfirmDialog.test.tsx
index a82dd401e..720e4b423 100644
--- a/client/src/components/shared/ConfirmDialog.test.tsx
+++ b/client/src/components/shared/ConfirmDialog.test.tsx
@@ -1,7 +1,11 @@
import { render, screen, fireEvent } from '../../../tests/helpers/render';
import userEvent from '@testing-library/user-event';
+import { waitFor } from '@testing-library/react';
import ConfirmDialog from './ConfirmDialog';
import Modal from './Modal';
+import { askNatively, canAskNatively } from '../../native/nativeDialogs';
+
+vi.mock('../../native/nativeDialogs', () => ({ canAskNatively: vi.fn(() => false), askNatively: vi.fn() }));
describe('ConfirmDialog', () => {
const onClose = vi.fn();
@@ -181,4 +185,51 @@ describe('ConfirmDialog', () => {
expect(onConfirm).not.toHaveBeenCalled();
});
});
+
+ describe('in the app, the system asks', () => {
+ afterEach(() => {
+ vi.mocked(canAskNatively).mockReturnValue(false);
+ vi.mocked(askNatively).mockReset();
+ });
+
+ it('FE-COMP-CONFIRM-NATIVE-001: asks once through the system, with the action in red, and confirms on yes', async () => {
+ vi.mocked(canAskNatively).mockReturnValue(true);
+ vi.mocked(askNatively).mockResolvedValue(true);
+ render();
+ await waitFor(() => expect(onClose).toHaveBeenCalledOnce());
+ expect(onConfirm).toHaveBeenCalledOnce();
+ expect(askNatively).toHaveBeenCalledTimes(1);
+ expect(askNatively).toHaveBeenCalledWith(
+ expect.objectContaining({ title: 'Delete place', message: 'Gone for good.', danger: true }),
+ );
+ expect(screen.queryByText('Gone for good.')).toBeNull();
+ });
+
+ it('FE-COMP-CONFIRM-NATIVE-002: a no only closes', async () => {
+ vi.mocked(canAskNatively).mockReturnValue(true);
+ vi.mocked(askNatively).mockResolvedValue(false);
+ render();
+ await waitFor(() => expect(onClose).toHaveBeenCalledOnce());
+ expect(onConfirm).not.toHaveBeenCalled();
+ });
+
+ it('FE-COMP-CONFIRM-NATIVE-003: falls back to the HTML card when the system cannot ask', async () => {
+ vi.mocked(canAskNatively).mockReturnValue(true);
+ vi.mocked(askNatively).mockResolvedValue(null);
+ render();
+ expect(await screen.findByText('Sure?')).toBeTruthy();
+ expect(onClose).not.toHaveBeenCalled();
+ });
+
+ it('FE-COMP-CONFIRM-NATIVE-004: keeps a question with a list under it in HTML', () => {
+ vi.mocked(canAskNatively).mockReturnValue(true);
+ render(
+
+
three places
+ ,
+ );
+ expect(screen.getByText('three places')).toBeTruthy();
+ expect(askNatively).not.toHaveBeenCalled();
+ });
+ });
});
diff --git a/client/src/components/shared/ConfirmDialog.tsx b/client/src/components/shared/ConfirmDialog.tsx
index bb7f494dd..1c283d3ff 100644
--- a/client/src/components/shared/ConfirmDialog.tsx
+++ b/client/src/components/shared/ConfirmDialog.tsx
@@ -5,6 +5,7 @@ import { useTranslation } from '../../i18n'
import { useIsPhone } from '../../mobile/useIsPhone'
import { DialogTile, NEUTRAL_TINT, fs } from './DialogShell'
import { useLastOpen, usePresence } from './usePresence'
+import { useNativeQuestion } from '../../native/useNativeQuestion'
interface ConfirmDialogProps {
isOpen: boolean
@@ -30,10 +31,25 @@ function runConfirm(onConfirm: () => void): void {
}
export default function ConfirmDialog(props: ConfirmDialogProps) {
- const { mounted, closing } = usePresence(props.isOpen)
+ const { t } = useTranslation()
+ // In the app the system asks (native/nativeDialogs.ts); a list under the question needs the HTML card.
+ const question = props.children
+ ? null
+ : {
+ title: props.title || t('common.confirm'),
+ message: props.message,
+ confirmLabel: props.confirmLabel || t('common.delete'),
+ cancelLabel: props.cancelLabel || t('common.cancel'),
+ danger: props.danger ?? true,
+ }
+ const html = useNativeQuestion(props.isOpen, question, (yes) => {
+ if (yes) runConfirm(props.onConfirm)
+ props.onClose()
+ })
+ const { mounted, closing } = usePresence(props.isOpen && html)
// The question stays readable while it fades, even when its owner clears the subject on close.
const shown = useLastOpen(props, props.isOpen)
- return mounted ? : null
+ return mounted ? : null
}
function ConfirmDialogFrame({
diff --git a/client/src/components/shared/CustomDateTimePicker.tsx b/client/src/components/shared/CustomDateTimePicker.tsx
index 8fe1ce2da..ce334a9e9 100644
--- a/client/src/components/shared/CustomDateTimePicker.tsx
+++ b/client/src/components/shared/CustomDateTimePicker.tsx
@@ -9,6 +9,7 @@ import { useDateFormat } from '../../hooks/useDateFormat';
import { useRemeasureSignal } from '../../hooks/useAnchoredPosition';
import { useWeekStartDay } from '../../hooks/useWeekStartDay';
import { leadingBlanks, weekdayLabels } from '../../utils/calendarWeek';
+import { selectionHaptic } from '../../native/haptics';
function daysInMonth(year: number, month: number): number {
return new Date(year, month + 1, 0).getDate();
@@ -178,6 +179,7 @@ export function CustomDatePicker({
const d = String(day).padStart(2, '0');
const iso = `${y}-${m}-${d}`;
if (isOutOfRange(iso)) return;
+ if (iso !== value) selectionHaptic();
onChange(iso);
setOpen(false);
};
diff --git a/client/src/components/shared/CustomSelect.tsx b/client/src/components/shared/CustomSelect.tsx
index af68a67be..704ca44f5 100644
--- a/client/src/components/shared/CustomSelect.tsx
+++ b/client/src/components/shared/CustomSelect.tsx
@@ -3,6 +3,7 @@ import { createPortal } from 'react-dom'
import { ChevronDown, Check } from 'lucide-react'
import { useAnchoredPosition, scrollAnchorIntoView } from '../../hooks/useAnchoredPosition'
import { useTranslation } from '../../i18n'
+import { selectionHaptic } from '../../native/haptics'
interface SelectOption {
// Callers use both string keys and numeric ids (e.g. day/place ids) as values, and
@@ -261,7 +262,7 @@ export default function CustomSelect({
type="text"
value={search}
onChange={e => setSearch(e.target.value)}
- placeholder={t('common.search')}
+ enterKeyHint="search" placeholder={t('common.search')}
aria-label={t('common.search')}
style={{
width: '100%', border: '1px solid var(--border-secondary)', borderRadius: 6,
@@ -305,7 +306,7 @@ export default function CustomSelect({