Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Shell: Ctrl+K and Ctrl+, wait while a sheet is up
Yashwanth Kamireddiceb8c9f6ff07
diff --git a/.uiverify/app-keys-modal.mjs b/.uiverify/app-keys-modal.mjsnew file mode 100644index 0000000..dbe61dd--- /dev/null+++ b/.uiverify/app-keys-modal.mjs@@ -0,0 +1,34 @@+// The keys that go anywhere wait while a sheet is up: Ctrl+K took the focus out of an open+// sheet into the search field behind its veil, and Ctrl+, changed the screen under it.+//+// URL=http://localhost:4203 ENGINE=webkit node .uiverify/app-keys-modal.mjs+import { engine, engineName } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const BASE = process.env.URL ?? "http://localhost:4173";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${engineName} ${m}`); if (!p) failures++; };+const ctx = await b.newContext({ viewport: { width: 1280, height: 820 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, notesFixture: true });+const page = await ctx.newPage();+page.on("pageerror", (e) => ok(false, `page error: ${e.message}`));+await page.goto(BASE, { waitUntil: "networkidle" });+await openScreen(page, "Notes");+await page.waitForTimeout(300);+await page.keyboard.press("Control+/");+const sheet = page.getByRole("dialog", { name: "Keyboard Shortcuts" });+await sheet.waitFor();+await page.keyboard.press("Control+k");+await page.waitForTimeout(150);+ok(await page.evaluate(() => Boolean(document.activeElement?.closest('[aria-modal="true"]'))), "Ctrl+K leaves the focus in the open sheet");+await page.keyboard.press("Control+,");+await page.waitForTimeout(200);+ok((await page.locator(".settings-title").count()) === 0 || !(await page.locator(".settings-title").isVisible()), "Ctrl+, does not change the screen under it");+await page.keyboard.press("Escape");+await page.waitForTimeout(150);+await page.keyboard.press("Control+,");+await page.locator(".settings-title").waitFor({ timeout: 2000 }).catch(() => {});+ok(await page.locator(".settings-title").isVisible(), "with the sheet put away, Ctrl+, opens Settings");+await b.close();+console.log(failures ? `\n${failures} FAILED` : "\nall passed");+process.exit(failures ? 1 : 0);diff --git a/src/components/GlobalSearch.tsx b/src/components/GlobalSearch.tsxindex c6b0765..ce34715 100644--- a/src/components/GlobalSearch.tsx+++ b/src/components/GlobalSearch.tsx@@ -29,6 +29,7 @@ import { api, contactPhotoSrc, pictureSrc, type SearchGroup, type SearchHit } frimport { reveal } from "../lib/reveal";import { AppIcon } from "./AppIcon";import { Portal } from "./Portal";+import { modalOpen } from "../lib/screen";/** The height of a result: fixed, so a long list is drawn only where it is in view. */const ROW = 44;@@ -204,6 +205,7 @@ export function GlobalSearch({const key = (e: KeyboardEvent) => {if ((e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey && e.key.toLowerCase() === "k") {e.preventDefault();+ if (modalOpen()) return;summon.current();}};diff --git a/src/lib/screen.ts b/src/lib/screen.tsindex 1a7abc4..10beafc 100644--- a/src/lib/screen.ts+++ b/src/lib/screen.ts@@ -26,6 +26,16 @@ export function useActiveRef() {* screen's own list of rows (a list box marked `data-rows`, as Notes and Contacts draw theirs)* is not one, and nothing in a screen kept out of sight counts.*/+/** Whether a modal sheet is up (a confirmation, Keyboard Shortcuts, an import): the keys that+ * go anywhere — Ctrl+K, Ctrl+, — wait until it is answered, rather than taking the focus out+ * of it or changing the screen under it. */+export function modalOpen(): boolean {+ for (const el of document.querySelectorAll('[aria-modal="true"]')) {+ if (!el.closest("[inert], [hidden]")) return true;+ }+ return false;+}+export function overlayOpen(): boolean {const open = document.querySelectorAll('[role="menu"], [role="listbox"], [role="dialog"], [role="alertdialog"], .confirm');for (const el of open) {diff --git a/src/screens/Library.tsx b/src/screens/Library.tsxindex 6d4dece..7de1a3e 100644--- a/src/screens/Library.tsx+++ b/src/screens/Library.tsx@@ -59,7 +59,7 @@ const DriveView = apps.drivews.Screen;const PhotosView = apps.photos.Screen;const SettingsView = apps.settings.Screen;import { ScreenBoundary } from "../components/ScreenBoundary";-import { ScreenActive } from "../lib/screen";+import { ScreenActive, modalOpen } from "../lib/screen";import { AppIcon } from "../components/AppIcon";import { GlobalSearch } from "../components/GlobalSearch";import { ShortcutsSheet } from "../components/ShortcutsSheet";@@ -116,6 +116,10 @@ function AppKeys({ screen, onSettings }: { screen: string | null; onSettings: ()useEffect(() => {const onKey = (e: KeyboardEvent) => {if (!(e.ctrlKey || e.metaKey) || e.altKey || e.defaultPrevented) return;+ if ((e.key === "," || e.key === "/" || e.key === "?") && modalOpen()) {+ e.preventDefault();+ return;+ }if (e.key === ",") {e.preventDefault();onSettings();