[ui] DomiUi: @domi/ui v1.2.0; on Android the town field is an editable box, so focusing it sends no Autofill request (TextField as=auto)

This commit is contained in:
2026-11-23 01:34:49 +01:00
parent 8018268821
commit 7f8b6861f9
17 changed files with 312 additions and 28 deletions
+8 -2
View File
@@ -30,6 +30,8 @@
// Raw: the towns are handed on as they came, never wrapped in a state Proxy.
let results = $state.raw<readonly NamedPlace[]>([]);
let input = $state<HTMLInputElement | HTMLTextAreaElement | null>(null);
// On Android the field is an editable box, not an <input> (as="auto" below): focus whichever there is.
let editor = $state<HTMLElement | null>(null);
// Only the latest query's answer is shown, however the searches finish.
let asked = 0;
@@ -52,7 +54,7 @@
});
$effect(() => {
if (focusOnOpen) input?.focus();
if (focusOnOpen) (input ?? editor)?.focus();
});
const where = (t: NamedPlace): string => [t.region, t.country].filter(Boolean).join(', ');
@@ -63,8 +65,11 @@
<p class="why">{en.sunset.why}</p>
<!-- The list already follows the typing; the seal and Enter only confirm it, so they say nothing of their own
(sentText) and the status line below speaks (domi-ui.md D4). Nothing is sent anywhere: "search", never "send". -->
(sentText) and the status line below speaks (domi-ui.md D4). Nothing is sent anywhere: "search", never "send".
as="auto": on Android an editable box, because a native field makes the WebView ask Google's Autofill service
the moment it gets focus, whatever the app's permissions (domi-ui.md D10). -->
<TextField
as="auto"
id="{uid}-search"
type="search"
label={en.sunset.searchLabel}
@@ -76,6 +81,7 @@
onsend={() => {}}
bind:value={query}
bind:input
bind:editor
/>
<p class="found" role="status" aria-live="polite">{query.trim() === '' ? '' : en.sunset.found(results.length)}</p>
+14
View File
@@ -45,6 +45,20 @@ describe('the garden asks where the sunset is', () => {
expect(document.activeElement).toBe(document.body);
});
it('on Android the town field is no native text field, so the WebView asks no Autofill service (domi-ui.md D10)', async () => {
vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Mozilla/5.0 (Linux; Android 16; WAVE 10C) AppleWebKit/537.36 Chrome/140.0 Mobile Safari/537.36');
render(Shell, { sunset: wiring() });
const field = await screen.findByRole('textbox', { name: en.sunset.searchLabel });
expect(field.getAttribute('contenteditable')).toBe('plaintext-only');
expect(document.querySelector('.ask input:not([type="hidden"]), .ask textarea')).toBeNull();
});
it('elsewhere it stays the native search field', async () => {
render(Shell, { sunset: wiring() });
expect(await screen.findByRole('searchbox', { name: en.sunset.searchLabel })).toBeTruthy();
expect(screen.queryByRole('textbox', { name: en.sunset.searchLabel })).toBeNull();
});
it('typing lists towns, choosing one shows its sunset, keeps it, and moves focus to the answer', async () => {
const w = wiring();
render(Shell, { sunset: w });