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.

Drive: a click selects and a double-click opens, as in Finder; Return opens and Delete deletes the selected item

Yashwanth Kamireddi5522ad5d2b6c
diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjs
index bb6bded..aa1a672 100644
--- a/.uiverify/assert.mjs
+++ b/.uiverify/assert.mjs
@@ -370,7 +370,7 @@ let failures = 0;
if ((await folderRow.count()) > 0) {
// Fire several clicks back to back, the way an impatient double-click does, before the
// slow folder load has had any chance to resolve.
- await Promise.all([folderRow.click(), folderRow.click(), folderRow.click()]);
+ await Promise.all([folderRow.dblclick(), folderRow.dblclick(), folderRow.dblclick()]);
await page.waitForTimeout(500);
const crumbs = await page.locator(".crumb").allInnerTexts();
const names = crumbs.slice(1);
diff --git a/.uiverify/drive-info.mjs b/.uiverify/drive-info.mjs
index ad78cde..70e91b1 100644
--- a/.uiverify/drive-info.mjs
+++ b/.uiverify/drive-info.mjs
@@ -28,5 +28,17 @@ ok(JSON.stringify(offered) === JSON.stringify(["Open", "Get Info", "Rename", "Mo
await page.keyboard.press("Escape");
await page.waitForTimeout(100);
ok((await page.getByRole("menu").count()) === 0, "and Escape puts it away");
+// A click selects, as in Finder; it does not download. A double-click opens.
+let downloads = 0;
+await page.evaluate(() => { const t = window.__TAURI_INTERNALS__; const inner = t.invoke;
+ t.invoke = async (c, a) => { if (c === "drive_download") window.__dl = (window.__dl ?? 0) + 1; return inner(c, a); }; });
+await page.locator(".drive-row-hit", { hasText: "Semester Plan" }).click();
+await page.waitForTimeout(200);
+downloads = await page.evaluate(() => window.__dl ?? 0);
+ok(downloads === 0 && (await page.locator(".drive-row.is-selected", { hasText: "Semester Plan" }).count()) === 1,
+ "a click selects the file, and downloads nothing");
+await page.locator(".drive-row-hit", { hasText: "Downloads" }).dblclick();
+await page.waitForTimeout(300);
+ok((await page.locator(".crumb", { hasText: "Downloads" }).count()) === 1, "a double-click opens the folder");
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/drive-nav.mjs b/.uiverify/drive-nav.mjs
index d545125..2fce446 100644
--- a/.uiverify/drive-nav.mjs
+++ b/.uiverify/drive-nav.mjs
@@ -36,7 +36,7 @@ await page.waitForTimeout(400);
let failures = 0;
const ok = (pass, yes, no) => { console.log(pass ? `PASS ${yes}` : `FAIL ${no}`); if (!pass) failures++; };
-await page.locator(".drive-row-hit", { hasText: "Downloads" }).click();
+await page.locator(".drive-row-hit", { hasText: "Downloads" }).dblclick();
await page.waitForTimeout(300);
const during = await page.locator(".drive-name").allInnerTexts();
ok(!during.includes("Keynote") && !during.includes("Semester Plan.pdf"),
@@ -56,7 +56,7 @@ ok(making.some((t) => t.includes("Trips") && t.includes("Creating")), "a new fol
`straight after Return: ${JSON.stringify(making)}`);
// Gone elsewhere before it finished: the folder on screen stays the one on screen. A refresh
// bound to where the work began re-read that folder at the end, and its rows replaced these.
-await page.locator(".drive-row-hit", { hasText: "Downloads" }).first().click();
+await page.locator(".drive-row-hit", { hasText: "Downloads" }).first().dblclick();
await page.waitForTimeout(2200);
const inDownloads = await page.locator(".drive-name").allInnerTexts();
await page.waitForTimeout(500);
diff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsx
index b5040c0..5001dec 100644
--- a/src/screens/DriveView.tsx
+++ b/src/screens/DriveView.tsx
@@ -261,6 +261,8 @@ export function DriveView() {
/** The item a Move dialog is open for, if any. */
const [moving, setMoving] = useState<DriveItem | null>(null);
const [info, setInfo] = useState<DriveItem | null>(null);
+ /** The one item selected, as a click in Finder selects it. */
+ const [selected, setSelected] = useState<string | null>(null);
/** The ⋯ menu, or the same menu opened by a right-click, for one item. */
const [menu, setMenu] = useState<{ item: DriveItem; x: number; y: number; alignRight: boolean } | null>(null);
/** True while files are held over the window, so the drop target can say so. */
@@ -775,7 +777,7 @@ export function DriveView() {
</div>
) : (
<div
- className={`drive-row${container ? " is-folder" : ""}${busy ? " is-busy" : ""}${menu?.item.drivewsid === item.drivewsid ? " is-menu" : ""}`}
+ className={`drive-row${container ? " is-folder" : ""}${busy ? " is-busy" : ""}${menu?.item.drivewsid === item.drivewsid ? " is-menu" : ""}${selected === item.drivewsid ? " is-selected" : ""}`}
onContextMenu={(e) => {
e.preventDefault();
if (!busy) setMenu({ item, x: e.clientX, y: e.clientY, alignRight: false });
@@ -783,10 +785,23 @@ export function DriveView() {
>
<button
className="drive-row-hit"
- // A folder opens; a file downloads to Downloads and reveals itself
- // there — the same gesture either way, matching what a click on a row
- // does in every real file browser.
- onClick={() => (container ? enter(item) : void download(item))}
+ // As Finder and icloud.com: a click selects, a double-click opens — a folder
+ // goes in, a file is saved to Downloads and shown there. Return opens the
+ // selected item too; a single click that opened made every misclick a
+ // download.
+ aria-pressed={selected === item.drivewsid}
+ onClick={() => setSelected(item.drivewsid)}
+ onDoubleClick={() => (container ? enter(item) : void download(item))}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ if (container) enter(item);
+ else void download(item);
+ } else if (e.key === "Delete" || (e.key === "Backspace" && (e.metaKey || e.ctrlKey))) {
+ e.preventDefault();
+ void remove(item);
+ }
+ }}
disabled={busy}
>
<span className="drive-badge" aria-hidden="true">
diff --git a/src/styles/app.css b/src/styles/app.css
index 70946d5..89fad68 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -1758,3 +1758,8 @@
.drive-row.is-menu { background: color-mix(in srgb, var(--text) 8%, transparent); }
.drive-row.is-menu .drive-row-actions { opacity: 1; }
.drive-count { margin: 0 auto 0 10px; color: var(--text-3); font-size: var(--t-12, 12px); white-space: nowrap; }
+/* Selected, as Finder marks it: the accent behind the row, its text in white. */
+.drive-row.is-selected { background: var(--sys-blue, #0a84ff); }
+.drive-row.is-selected .drive-name, .drive-row.is-selected .drive-meta { color: #fff; }
+.drive-rows.is-grid .drive-row.is-selected { background: color-mix(in srgb, var(--sys-blue, #0a84ff) 28%, transparent); box-shadow: inset 0 0 0 2px var(--sys-blue, #0a84ff); }
+.drive-rows.is-grid .drive-row.is-selected .drive-name { color: var(--text); }