Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Reminders: Tab after renaming keeps the cursor in the title

Yashwanth Kamireddi8a1ba6bc99c7
diff --git a/.uiverify/reminders-tab-focus.mjs b/.uiverify/reminders-tab-focus.mjs
new file mode 100644
index 0000000..4341f50
--- /dev/null
+++ b/.uiverify/reminders-tab-focus.mjs
@@ -0,0 +1,29 @@
+// Renamed and then tucked under the one above with Tab, a reminder's title keeps the cursor,
+// as on the Mac, so typing goes on in it. The rename had redrawn the field and dropped it.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const BASE = process.env.BASE ?? "http://localhost:4202";
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true });
+const page = await ctx.newPage();
+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); failures++; });
+await page.goto(BASE, { waitUntil: "networkidle" });
+await openScreen(page, "Reminders");
+await page.locator(".rx-list", { hasText: "Daily" }).click();
+await page.waitForTimeout(400);
+const field = page.getByLabel("Rename Pick up the parcel");
+await field.click();
+await page.keyboard.press("End");
+await page.keyboard.type(" today");
+await page.keyboard.press("Tab");
+await page.waitForTimeout(400);
+const where = await page.evaluate(() => document.activeElement?.classList.contains("rx-title") ? document.activeElement.value : document.activeElement?.className);
+ok(where === "Pick up the parcel today", `the title keeps the cursor after Tab (${JSON.stringify(where)})`);
+await page.keyboard.type("!");
+const now = await page.locator(".rx-title").evaluateAll((els) => els.map((e) => e.value));
+ok(now.includes("Pick up the parcel today!"), `and typing goes on in it ${JSON.stringify(now)}`);
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index 8f4d755..1aaa972 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -2318,8 +2318,21 @@ const ReminderRow = memo(function ReminderRow({
e.preventDefault();
const typed = e.currentTarget.value;
const out = e.key === "[" || (e.key === "Tab" && e.shiftKey);
- void act.current.rename(reminder, typed);
- void (out ? (reminder.parentGuid ? act.current.outdent(reminder) : null) : (reminder.parentGuid ? null : act.current.indent(reminder)));
+ const caret = e.currentTarget.selectionStart ?? typed.length;
+ const renamed = act.current.rename(reminder, typed);
+ const moved = out ? (reminder.parentGuid ? act.current.outdent(reminder) : null) : (reminder.parentGuid ? null : act.current.indent(reminder));
+ // The cursor stays in the title, as on the Mac: the rename redraws the field (and
+ // the move the row), which had dropped it.
+ const refocus = () => {
+ const active = document.activeElement;
+ if (active && active !== document.body && !active.closest(".rx-row")) return;
+ const field = document.querySelector<HTMLInputElement>(`.rx-row[data-guid="${CSS.escape(reminder.guid)}"] .rx-title`);
+ if (!field || field === active) return;
+ field.focus();
+ field.setSelectionRange(caret, caret);
+ };
+ window.setTimeout(refocus, 0);
+ void Promise.all([renamed, moved]).then(refocus, refocus);
} else if ((e.key === "ArrowUp" || e.key === "ArrowDown") && !e.shiftKey && !e.altKey) {
// Up and Down walk the list, keeping where the caret was.
const all = [...document.querySelectorAll<HTMLInputElement>(".rx-row .rx-title")];