A landed upload keeps its row as a press-away record — the cancel ✕ had nothing left to cancel, so the finished row drops it and clears itself on click or Enter
Browse files at this commit6cb90b434736db49a391aa90e6ed68ff5ec04487Parent: dbcb288- fix
- a landed upload keeps its row as a press-away record — the cancel ✕ had nothing left to cancel, so the finished row drops it and clears itself on click or Enter
2 changed files +54 -14
- crates/in-web/src/drive.rs +44 -14
- style/main.scss +10 -0
crates/in-web/src/drive.rsmodified+44 -14
| @@ -559,9 +559,7 @@ async fn drive(cx: &Cx) -> Result { | |||
| 559 | // owned and live opens nothing. | 559 | // owned and live opens nothing. |
| 560 | let share_pair = params.as_ref().and_then(|query| query.share.as_deref()); | 560 | let share_pair = params.as_ref().and_then(|query| query.share.as_deref()); |
| 561 | let share_dialog = match share_pair.and_then(|pair| pair.split_once(':')) { | 561 | let share_dialog = match share_pair.and_then(|pair| pair.split_once(':')) { |
| 562 | - Some((kind, id)) => { | 562 | + Some((kind, id)) => crate::share::share_modal(cx, kind, id, &here, created.clone()).await?, |
| 563 | - crate::share::share_modal(cx, kind, id, &here, created.clone()).await? | ||
| 564 | - } | ||
| 565 | None => None, | 563 | None => None, |
| 566 | }; | 564 | }; |
| 567 | // The move picker: `?move=kind:id` renders the destination modal over | 565 | // The move picker: `?move=kind:id` renders the destination modal over |
| @@ -915,6 +913,12 @@ fn query_value(query: &str, key: &str) -> Option<String> { | |||
| 915 | /// so the row's ✕ keeps working across soft navigations — then the row | 913 | /// so the row's ✕ keeps working across soft navigations — then the row |
| 916 | /// drops and the canceled card announces through `window.__inNotify`. | 914 | /// drops and the canceled card announces through `window.__inNotify`. |
| 917 | /// | 915 | /// |
| 916 | +/// A finished upload keeps its row — at 100 percent, without the ✕ (there | ||
| 917 | +/// is nothing left to cancel once the bytes have landed) — and the row | ||
| 918 | +/// itself becomes the dismissal: pressing it anywhere (click, Enter, Space) | ||
| 919 | +/// drops it from the stack and the mirror, so the record lingers exactly | ||
| 920 | +/// as long as the reader wants it. | ||
| 921 | +/// | ||
| 918 | /// The form wears `data-hard` so the soft-nav's multipart replay leaves it | 922 | /// The form wears `data-hard` so the soft-nav's multipart replay leaves it |
| 919 | /// alone — two uploaders racing the same bytes would double-insert, and the | 923 | /// alone — two uploaders racing the same bytes would double-insert, and the |
| 920 | /// progress the soft-nav draws knows nothing of chunks. Without script the | 924 | /// progress the soft-nav draws knows nothing of chunks. Without script the |
| @@ -990,21 +994,41 @@ async fn upload_script(cx: &Cx) -> Result { | |||
| 990 | track.appendChild(fill); \ | 994 | track.appendChild(fill); \ |
| 991 | var pct = document.createElement('span'); \ | 995 | var pct = document.createElement('span'); \ |
| 992 | pct.className = 'upload-progress-pct'; \ | 996 | pct.className = 'upload-progress-pct'; \ |
| 993 | - var shut = document.createElement('button'); \ | 997 | + if (!u.done) { \ |
| 994 | - shut.type = 'button'; \ | 998 | + var shut = document.createElement('button'); \ |
| 995 | - shut.className = 'upload-progress-cancel'; \ | 999 | + shut.type = 'button'; \ |
| 996 | - shut.textContent = '✕'; \ | 1000 | + shut.className = 'upload-progress-cancel'; \ |
| 997 | - if (u.cancelLabel) { shut.setAttribute('aria-label', u.cancelLabel); } \ | 1001 | + shut.textContent = '✕'; \ |
| 998 | - shut.addEventListener('click', function () { \ | 1002 | + if (u.cancelLabel) { shut.setAttribute('aria-label', u.cancelLabel); } \ |
| 999 | - shut.disabled = true; \ | 1003 | + shut.addEventListener('click', function () { \ |
| 1000 | - if (u.cancel) { u.cancel(); } \ | 1004 | + shut.disabled = true; \ |
| 1001 | - }); \ | 1005 | + if (u.cancel) { u.cancel(); } \ |
| 1006 | + }); \ | ||
| 1007 | + row.appendChild(shut); \ | ||
| 1008 | + } \ | ||
| 1002 | row.appendChild(name); \ | 1009 | row.appendChild(name); \ |
| 1003 | row.appendChild(track); \ | 1010 | row.appendChild(track); \ |
| 1004 | row.appendChild(pct); \ | 1011 | row.appendChild(pct); \ |
| 1005 | - row.appendChild(shut); \ | ||
| 1006 | box.appendChild(window.__inAdded(row)); \ | 1012 | box.appendChild(window.__inAdded(row)); \ |
| 1007 | } \ | 1013 | } \ |
| 1014 | + /* A finished upload turns its row into the completion \ | ||
| 1015 | + notice: nothing is left to cancel — the bytes already \ | ||
| 1016 | + landed — so the ✕ goes and the row's own press \ | ||
| 1017 | + clears it. The flag on the node keeps a re-render \ | ||
| 1018 | + from stacking handlers on one survivor. */ \ | ||
| 1019 | + if (u.done && !row.__inDone) { \ | ||
| 1020 | + row.__inDone = true; \ | ||
| 1021 | + row.classList.add('upload-progress-done'); \ | ||
| 1022 | + var old = row.querySelector('.upload-progress-cancel'); \ | ||
| 1023 | + if (old) { old.remove(); } \ | ||
| 1024 | + row.setAttribute('role', 'button'); \ | ||
| 1025 | + row.setAttribute('tabindex', '0'); \ | ||
| 1026 | + row.setAttribute('title', box.getAttribute('data-dismiss-label') || 'dismiss'); \ | ||
| 1027 | + row.addEventListener('click', function () { dropRow(u); }); \ | ||
| 1028 | + row.addEventListener('keydown', function (ev) { \ | ||
| 1029 | + if (ev.key === 'Enter' || ev.key === ' ') { ev.preventDefault(); dropRow(u); } \ | ||
| 1030 | + }); \ | ||
| 1031 | + } \ | ||
| 1008 | var text = Math.min(100, Math.round(u.frac * 100)) + '%'; \ | 1032 | var text = Math.min(100, Math.round(u.frac * 100)) + '%'; \ |
| 1009 | var fillNow = row.querySelector('.upload-progress-fill'); \ | 1033 | var fillNow = row.querySelector('.upload-progress-fill'); \ |
| 1010 | var pctNow = row.querySelector('.upload-progress-pct'); \ | 1034 | var pctNow = row.querySelector('.upload-progress-pct'); \ |
| @@ -1048,6 +1072,11 @@ async fn upload_script(cx: &Cx) -> Result { | |||
| 1048 | var row = box && findRow(box, u.id); \ | 1072 | var row = box && findRow(box, u.id); \ |
| 1049 | if (row) { row.remove(); } \ | 1073 | if (row) { row.remove(); } \ |
| 1050 | } \ | 1074 | } \ |
| 1075 | + /* Completion keeps the row as a record instead of dropping it: \ | ||
| 1076 | + the flag re-renders it read-only (no ✕) and press-clears, so \ | ||
| 1077 | + a landed upload announces itself exactly as long as the \ | ||
| 1078 | + reader wants it on screen. */ \ | ||
| 1079 | + function finishRow(u) { u.done = true; renderUploads(); } \ | ||
| 1051 | document.addEventListener('in:wire', renderUploads); \ | 1080 | document.addEventListener('in:wire', renderUploads); \ |
| 1052 | renderUploads(); \ | 1081 | renderUploads(); \ |
| 1053 | function notify(kind, message) { \ | 1082 | function notify(kind, message) { \ |
| @@ -1244,13 +1273,14 @@ async fn upload_script(cx: &Cx) -> Result { | |||
| 1244 | var ui = bar(title); \ | 1273 | var ui = bar(title); \ |
| 1245 | rows.push(ui); \ | 1274 | rows.push(ui); \ |
| 1246 | var url = await sendSmall(form.getAttribute('action'), folder, small, function (frac) { setProgress(ui, frac); }, ui); \ | 1275 | var url = await sendSmall(form.getAttribute('action'), folder, small, function (frac) { setProgress(ui, frac); }, ui); \ |
| 1276 | + finishRow(ui); \ | ||
| 1247 | if (url) { landing = url; } \ | 1277 | if (url) { landing = url; } \ |
| 1248 | } \ | 1278 | } \ |
| 1249 | for (var i = 0; i < big.length; i++) { \ | 1279 | for (var i = 0; i < big.length; i++) { \ |
| 1250 | await (function (file) { \ | 1280 | await (function (file) { \ |
| 1251 | var ui2 = bar(file.name); \ | 1281 | var ui2 = bar(file.name); \ |
| 1252 | rows.push(ui2); \ | 1282 | rows.push(ui2); \ |
| 1253 | - return sendBig(file, folder, function (frac) { setProgress(ui2, frac); }, ui2); \ | 1283 | + return sendBig(file, folder, function (frac) { setProgress(ui2, frac); }, ui2).then(function () { finishRow(ui2); }); \ |
| 1254 | })(big[i]); \ | 1284 | })(big[i]); \ |
| 1255 | } \ | 1285 | } \ |
| 1256 | } catch (err) { \ | 1286 | } catch (err) { \ |
style/main.scssmodified+10 -0
| @@ -4653,6 +4653,16 @@ input[type="radio"] { | |||
| 4653 | color: var(--muted-soft); | 4653 | color: var(--muted-soft); |
| 4654 | } | 4654 | } |
| 4655 | 4655 | ||
| 4656 | +// A finished row is its own dismissal: no cancel control is drawn (nothing | ||
| 4657 | +// is left to cancel), so the press of the row has to read as the way out — | ||
| 4658 | +// a pointer, and a hover that lifts the muted name to ink. The shared | ||
| 4659 | +// `[tabindex]` ring rule covers keyboard focus. | ||
| 4660 | +.upload-progress-done { | ||
| 4661 | + cursor: pointer; | ||
| 4662 | + | ||
| 4663 | + &:hover .upload-progress-name { color: var(--ink); } | ||
| 4664 | +} | ||
| 4665 | + | ||
| 4656 | // The full-page drop affordance: a fixed veil with the invitation centred, | 4666 | // The full-page drop affordance: a fixed veil with the invitation centred, |
| 4657 | // pointer-transparent so it never blocks the drop it announces. | 4667 | // pointer-transparent so it never blocks the drop it announces. |
| 4658 | .drop-overlay { | 4668 | .drop-overlay { |