Focus the drawer's search and raise the keyboard when the drawer opens

Swiping down to the app drawer puts the cursor in its search box. A WebView
won't show the keyboard for a script focus(), so the shell does it through
new Android.showKeyboard/hideKeyboard bridge calls; closing the drawer hides
it again. Pick mode (adding apps) stays keyboard-free.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169wSWnZqnXBsJKMPAiCCNG
This commit is contained in:
Claude committed 2026-10-21 23:54:41 +00:00
1 parent ce815d72c2
commit be2371deb0
3 files changed
+39 -1

No files matched your search

+21 -1
View File
@@ -32,6 +32,8 @@
openSettings: () => toast("Open system settings"),
pickWallpaper: () => toast("Pick a wallpaper"),
openRecents: () => toast("Show open windows"),
showKeyboard: () => {},
hideKeyboard: () => {},
haptic: () => navigator.vibrate?.(10),
};
if (!window.Android) document.documentElement.classList.add("demo");
@@ -54,6 +56,24 @@
};
let excluded = "[]";
// Opening the drawer puts the cursor in its search box and raises the keyboard
// (a WebView won't show it for a focus() the user didn't tap, so the shell does).
// Picking apps to add is for scrolling, so that stays keyboard-free.
let drawerOpen = false;
const watchDrawer = () => {
const d = document.querySelector(".drawer");
if (!!d === drawerOpen) return;
drawerOpen = !!d;
if (d) {
if (d.classList.contains("picking")) return;
d.querySelector(".drawer-head input")?.focus({ preventScroll: true });
host.showKeyboard?.();
} else {
document.activeElement?.blur?.();
host.hideKeyboard?.();
}
};
// Icons: each <img class="icon" data-icon=KEY> gets its src from here. On a phone the
// shell draws icons on its own thread and hands them back as data: URIs in batches
// (ultraIcons), so the WebView never loads icons through request interception.
@@ -95,7 +115,7 @@
window.ultraIcons = gotIcons; // the shell calls this before ultraHome exists, too
const app = await mount("#app", "./app.wasm", {
onRender: () => { fillIcons(); place(); },
onRender: () => { fillIcons(); place(); watchDrawer(); },
imports: ({ strs }) => ({
launch: (h) => host.launch(strs[h]),
app_info: (h) => host.appInfo(strs[h]),