forge
Explore
Log in

Don't you dare go Hollow

The whole control box opens its dropdown, and the photo uploads

Browse files at this commit

0c31c238c1a28dcdbd8c12907988e7c7aebc4e32Ahmet Kaan GümüşParent: 5189bb9
  • fix
    • the whole control box opens its dropdown, and the photo uploads
Show full message
🐛 fix(web): the whole control box opens its dropdown, and the photo uploads

Three bugs and a redesign, all from driving the real pages.

The profile photo silently never uploaded. The shared file-input handler
read `.file-upload-name` out of the input's label and set its text; the
photo's label holds an avatar and no such span, so the read threw and the
`requestSubmit` on the next line never ran. Nothing failed loudly — clean
build, green tests, a picked file and no picture. The lookup is guarded,
and the rule is written down: a shared handler never assumes an optional
node, and the work that must happen goes before the decoration that
might not.

The status control had dead zones everywhere it looked clickable — the
chevron, the dot, the gaps, the box's own padding — because only the
inner button listened. This is the version that cannot come back: a
delegated listener walks up from whatever was clicked and opens the
element that *directly* contains a single trigger. That pins the hit
area to the visual box and no further, and a new select inherits it by
existing rather than by remembering to opt in.

It needs `preventDefault` as much as `stopPropagation`: the new-task
modal wraps its box in a `<label>`, which forwards a second click to the
control, and that second click toggled the panel shut in the same
gesture — indistinguishable from the dead zone being fixed. Every
trigger on the board, the new-task modal, the detail page and settings
was then clicked at four edges each.

A subtask now says where it belongs in a way that can be clicked: an
arrow, the parent's key and the parent's title. "Part of DZ-14" was a
caption, and a caption is not a way back.

And the subtask row is lighter than the dependency row it borrowed from
— a rule between rows rather than a box each, one link across the key
and title rather than two a pointer can fall between, a hollow ring for
an open part instead of the padlock that means "blocked" three rows up,
and no strikethrough fighting the hover underline.
crates/izlek-web/src/detail.rsmodified+27 -6
@@ -946,6 +946,19 @@ pub(crate) mod glyph {
946 }946 }
947 }947 }
948 948
949+ /// An open part. Deliberately not the padlock: a dependency row's lock
950+ /// means "something is in front of this", and a subtask that is simply
951+ /// unfinished is not blocked by anything.
952+ pub async fn ring(cx: &Cx) -> Result {
953+ view! {
954+ cx =>
955+ <svg class="glyph" width="12" height="12" viewBox="0 0 16 16" fill="none"
956+ stroke="currentColor" stroke-width="1.6" aria-hidden="true">
957+ <circle cx="8" cy="8" r="5"></circle>
958+ </svg>
959+ }
960+ }
961+
949 pub async fn tick(cx: &Cx) -> Result {962 pub async fn tick(cx: &Cx) -> Result {
950 view! {963 view! {
951 cx =>964 cx =>
@@ -1409,12 +1422,18 @@ async fn subtask_row(
1409 }1422 }
1410 view! {1423 view! {
1411 cx =>1424 cx =>
1412- <div class=(class!("dep-row", "subtask-row-done" if done))>1425+ <div class=(class!("subtask-row", "subtask-row-done" if done))>
1413- if done { (glyph::tick(cx).await?) } else { (glyph::lock(cx).await?) }1426+ // One link, not two: the key and the title are the same target,
1414- <a class="dep-key" href=(href.clone())>(part.task_key.clone())</a>1427+ // so the whole of the row's text is the way in.
1415- <a class="dep-title" href=(href)>(part.title.clone())</a>1428+ <a class="subtask-open" href=(href)>
1429+ <span class="subtask-mark">
1430+ if done { (glyph::tick(cx).await?) } else { (glyph::ring(cx).await?) }
1431+ </span>
1432+ <span class="subtask-key">(part.task_key.clone())</span>
1433+ <span class="subtask-title">(part.title.clone())</span>
1434+ </a>
1416 <div class="spacer"></div>1435 <div class="spacer"></div>
1417- <span class="dep-note">(status)</span>1436+ <span class="subtask-status">(status)</span>
1418 <div class="avatars">1437 <div class="avatars">
1419 for face in faces { (face) }1438 for face in faces { (face) }
1420 </div>1439 </div>
@@ -1683,7 +1702,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
1683 <div class="detail-headline">1702 <div class="detail-headline">
1684 if let Some(parent) = detail.parent.clone() {1703 if let Some(parent) = detail.parent.clone() {
1685 <a class="detail-parent" href=(format!("/?task={}", parent.id))>1704 <a class="detail-parent" href=(format!("/?task={}", parent.id))>
1686- (format!("{} {}", t(lang, Key::PartOf), parent.task_key))1705+ <span class="detail-parent-arrow">"\u{2190}"</span>
1706+ <span class="detail-parent-key">(parent.task_key.clone())</span>
1707+ <span class="detail-parent-title">(parent.title.clone())</span>
1687 </a>1708 </a>
1688 }1709 }
1689 <span class="detail-key">(detail.task_key.clone())</span>1710 <span class="detail-key">(detail.task_key.clone())</span>
crates/izlek-web/src/dropdown.rsmodified+48 -0
@@ -10,6 +10,33 @@
10 //! visible trigger — same closed look as the select it replaces — and a10 //! visible trigger — same closed look as the select it replaces — and a
11 //! `position: fixed` panel of option rows, portaled onto `<body>`, stands11 //! `position: fixed` panel of option rows, portaled onto `<body>`, stands
12 //! in for the OS popup.12 //! in for the OS popup.
13+//!
14+//! ## The whole box is the hit area
15+//!
16+//! The trigger is one child among several inside a control box — a status
17+//! dot before it, a chevron after it, the box's own padding around all of
18+//! them — so a button-only listener leaves dead zones exactly where the
19+//! control looks clickable. That bug has been fixed one control at a time
20+//! before; this is the version that cannot come back. A delegated listener
21+//! walks up from whatever was clicked and, on finding the element that
22+//! *directly* contains a single `.dd-trigger`, opens that trigger's panel.
23+//!
24+//! "Directly contains" is the whole of the rule: it pins the hit area to
25+//! the visual box and no further, so a click on a field's outer row or on
26+//! the modal around it does not reach in and open something. Nothing has to
27+//! be marked up for this to work — a new control gets it by existing, which
28+//! is what makes it structural rather than another remembered convention.
29+//!
30+//! Anything else genuinely interactive keeps its own click — a link, a
31+//! button, a text field. `<label>` is deliberately *not* on that list: the
32+//! new-task modal wraps its status box in one, and bailing on labels put
33+//! every dead zone straight back.
34+//!
35+//! The delegated click also calls `preventDefault`. A `<label>` forwards a
36+//! click to the control it labels, so without it the browser delivered a
37+//! *second* click straight to the trigger, which toggled the panel shut
38+//! again in the same gesture — opening and closing looked exactly like the
39+//! dead zone the delegation was added to remove.
13 40
14 use topcoat::Result;41 use topcoat::Result;
15 use topcoat::context::Cx;42 use topcoat::context::Cx;
@@ -115,6 +142,8 @@ pub async fn dropdown_script(cx: &Cx) -> Result {
115 panel.className = 'dd-panel';\142 panel.className = 'dd-panel';\
116 panel.setAttribute('role', 'listbox');\143 panel.setAttribute('role', 'listbox');\
117 panel.__ddTrigger = trigger;\144 panel.__ddTrigger = trigger;\
145+ trigger.__ddPanel = panel;\
146+ trigger.__ddSelect = select;\
118 var allOpts = opts(select);\147 var allOpts = opts(select);\
119 var search = null;\148 var search = null;\
120 if (allOpts.length > 7 || select.hasAttribute('data-search')) {\149 if (allOpts.length > 7 || select.hasAttribute('data-search')) {\
@@ -189,6 +218,25 @@ pub async fn dropdown_script(cx: &Cx) -> Result {
189 if (trigger) { trigger.focus(); }\218 if (trigger) { trigger.focus(); }\
190 return true;\219 return true;\
191 });\220 });\
221+ document.addEventListener('click', function (e) {\
222+ var el = e.target;\
223+ if (!el || !el.closest) { return; }\
224+ if (el.closest('.dd-panel') || el.closest('.dd-trigger')) { return; }\
225+ if (el.closest('a, button, input:not([type=hidden]), textarea')) { return; }\
226+ var box = el.nodeType === 1 ? el : el.parentNode;\
227+ for (var depth = 0; depth < 3 && box && box.querySelectorAll; depth++) {\
228+ var found = box.querySelectorAll('.dd-trigger');\
229+ if (found.length === 1 && found[0].parentNode === box && found[0].__ddPanel) {\
230+ var t = found[0];\
231+ e.stopPropagation();\
232+ e.preventDefault();\
233+ if (t.__ddPanel.classList.contains('dd-open')) { closeAll(); }\
234+ else { openPanel(t.__ddSelect, t, t.__ddPanel); }\
235+ return;\
236+ }\
237+ box = box.parentNode;\
238+ }\
239+ }, true);\
192 document.addEventListener('click', closeAll);\240 document.addEventListener('click', closeAll);\
193 window.addEventListener('scroll', function (e) {\241 window.addEventListener('scroll', function (e) {\
194 var t = e.target;\242 var t = e.target;\
crates/izlek-web/src/i18n.rsmodified+0 -3
@@ -289,7 +289,6 @@ pub enum Key {
289 NoSubtasks,289 NoSubtasks,
290 NewSubtask,290 NewSubtask,
291 AddSubtask,291 AddSubtask,
292- PartOf,
293 MakeAPart,292 MakeAPart,
294 ReleaseThisPart,293 ReleaseThisPart,
295 ExistingTask,294 ExistingTask,
@@ -844,8 +843,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
844 (NewSubtask, Tr) => "Alt görev",843 (NewSubtask, Tr) => "Alt görev",
845 (AddSubtask, En) => "Add",844 (AddSubtask, En) => "Add",
846 (AddSubtask, Tr) => "Ekle",845 (AddSubtask, Tr) => "Ekle",
847- (PartOf, En) => "Part of",
848- (PartOf, Tr) => "Şunun parçası:",
849 (MakeAPart, En) => "Take an existing task",846 (MakeAPart, En) => "Take an existing task",
850 (MakeAPart, Tr) => "Var olan görevi al",847 (MakeAPart, Tr) => "Var olan görevi al",
851 (ReleaseThisPart, En) => "Release this subtask",848 (ReleaseThisPart, En) => "Release this subtask",
crates/izlek-web/src/layout.rsmodified+3 -2
@@ -262,8 +262,9 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
262 document.addEventListener('change', function (e) { \262 document.addEventListener('change', function (e) { \
263 var control = e.target; \263 var control = e.target; \
264 if (control.classList && control.classList.contains('file-upload-input')) { \264 if (control.classList && control.classList.contains('file-upload-input')) { \
265- var name = control.closest('label').querySelector('.file-upload-name'); \265+ var label = control.closest('label'); \
266- if (control.files && control.files[0]) { name.textContent = control.files[0].name; } \266+ var name = label ? label.querySelector('.file-upload-name') : null; \
267+ if (name && control.files && control.files[0]) { name.textContent = control.files[0].name; } \
267 control.form.requestSubmit(); \268 control.form.requestSubmit(); \
268 return; \269 return; \
269 } \270 } \
crates/izlek-web/tests/http.rsmodified+63 -2
@@ -1517,9 +1517,14 @@ async fn taking_a_task_in_and_letting_it_out_are_the_same_form() {
1517 // The subtask kept its column: being taken in is not a move.1517 // The subtask kept its column: being taken in is not a move.
1518 let page = app.get(&format!("/?task={loose}"), Some(&admin)).await;1518 let page = app.get(&format!("/?task={loose}"), Some(&admin)).await;
1519 let page = String::from_utf8_lossy(&page.bytes);1519 let page = String::from_utf8_lossy(&page.bytes);
1520+ // The way back up: a link that names the whole, not a caption.
1520 assert!(1521 assert!(
1521- page.contains("Part of"),1522+ page.contains("detail-parent") && page.contains(&format!("/?task={parent}")),
1522- "the part does not name its whole"1523+ "the part does not link back to its whole"
1524+ );
1525+ assert!(
1526+ page.contains("Ship the exporter"),
1527+ "the link back does not name the task it goes to"
1523 );1528 );
1524 1529
1525 let released = app1530 let released = app
@@ -1700,6 +1705,62 @@ async fn a_parents_own_part_is_not_offered_as_a_blocker() {
1700 );1705 );
1701 }1706 }
1702 1707
1708+#[tokio::test]
1709+async fn a_file_input_without_a_name_label_still_submits() {
1710+ // The shared change handler used to read `.file-upload-name` out of the
1711+ // input's label and set its text. The profile photo's label holds an
1712+ // avatar and no such span, so the read threw and the submit that came
1713+ // after it never ran — the photo silently never uploaded. The handler
1714+ // tolerates a missing name now; this holds both halves of that.
1715+ let app = App::open().await;
1716+ let admin = admin(&app).await;
1717+ let page = app.get("/settings", Some(&admin)).await;
1718+ let page = String::from_utf8_lossy(&page.bytes);
1719+
1720+ assert!(
1721+ page.contains("avatar-upload"),
1722+ "the profile photo control is gone"
1723+ );
1724+ assert!(
1725+ page.contains("var name = label ? label.querySelector('.file-upload-name') : null"),
1726+ "the file-input handler assumes a name label again"
1727+ );
1728+ assert!(
1729+ page.contains("if (name && control.files && control.files[0])"),
1730+ "the name write is unguarded again"
1731+ );
1732+}
1733+
1734+#[tokio::test]
1735+async fn the_whole_control_box_opens_its_dropdown() {
1736+ // A status control is a box holding a dot, the trigger and a chevron.
1737+ // Listening on the trigger alone leaves every other part of the box dead
1738+ // where it looks clickable. The delegated listener walks up to whatever
1739+ // *directly* contains a single trigger, which pins the hit area to the
1740+ // visual box and needs no markup to opt in.
1741+ let app = App::open().await;
1742+ let admin = admin(&app).await;
1743+ let columns = columns_of(&app).await;
1744+ let task = a_task(&app, &admin, &columns[0], "Anything").await;
1745+ let page = app.get(&format!("/?task={task}"), Some(&admin)).await;
1746+ let page = String::from_utf8_lossy(&page.bytes);
1747+
1748+ assert!(
1749+ page.contains("found[0].parentNode === box"),
1750+ "the dropdown hit area is back to the button alone"
1751+ );
1752+ assert!(
1753+ page.contains("trigger.__ddPanel = panel"),
1754+ "a delegated click can no longer reach the panel"
1755+ );
1756+ // The box really is a box with siblings around the select — which is the
1757+ // shape that made the button-only listener wrong in the first place.
1758+ assert!(
1759+ page.contains("status-dot") && page.contains("status-select"),
1760+ "the status control changed shape"
1761+ );
1762+}
1763+
1703 #[tokio::test]1764 #[tokio::test]
1704 async fn a_drop_decided_against_a_stale_board_is_refused() {1765 async fn a_drop_decided_against_a_stale_board_is_refused() {
1705 let app = App::open().await;1766 let app = App::open().await;
style/main.scssmodified+77 -12
@@ -1446,16 +1446,35 @@ img.avatar {
1446 color: var(--muted-soft);1446 color: var(--muted-soft);
1447 }1447 }
1448 1448
1449-// A subtask says whose part it is above its own key, so the page it opens on1449+// A subtask names the whole it belongs to, above its own key, and that name
1450-// still names the work it belongs to.1450+// is the way back up. An arrow and the parent's title rather than a bare
1451+// caption: "Part of DZ-14" read as a label, and nobody tried to click it.
1451 .detail-parent {1452 .detail-parent {
1452- display: block;1453+ display: flex;
1453- font-family: var(--font-mono);1454+ align-items: center;
1455+ gap: 6px;
1454 font-size: 11px;1456 font-size: 11px;
1455 color: var(--muted);1457 color: var(--muted);
1456 text-decoration: none;1458 text-decoration: none;
1459+ width: fit-content;
1457 1460
1458- &:hover { color: var(--ink); }1461+ &:hover {
1462+ color: var(--ink);
1463+
1464+ .detail-parent-title { text-decoration: underline; }
1465+ }
1466+}
1467+
1468+.detail-parent-arrow,
1469+.detail-parent-key {
1470+ font-family: var(--font-mono);
1471+}
1472+
1473+.detail-parent-title {
1474+ overflow: hidden;
1475+ text-overflow: ellipsis;
1476+ white-space: nowrap;
1477+ max-width: 30ch;
1459 }1478 }
1460 1479
1461 .detail-title {1480 .detail-title {
@@ -1943,14 +1962,60 @@ img.avatar {
1943 font-size: 13px;1962 font-size: 13px;
1944 }1963 }
1945 1964
1946-// A finished part reads back the way a finished card does: still there,1965+// A part is a lighter thing than a dependency: no box of its own, a rule
1947-// still legible, plainly no longer in the way.1966+// between rows instead, so a list of eight does not read as eight cards.
1948-.subtask-row-done {1967+.subtask-row {
1949- .dep-key,1968+ display: flex;
1950- .dep-title,1969+ align-items: center;
1951- .dep-note { color: var(--muted-soft); }1970+ gap: 10px;
1971+ padding: 8px 4px;
1972+ border-bottom: 1px solid var(--border);
1973+ font-size: 13px;
1952 1974
1953- .dep-title { text-decoration: line-through; }1975+ &:last-child { border-bottom: none; }
1976+}
1977+
1978+// The key and the title are one target, so the row has one way in rather
1979+// than two adjacent links a pointer can fall between.
1980+.subtask-open {
1981+ display: flex;
1982+ align-items: center;
1983+ gap: 10px;
1984+ min-width: 0;
1985+ color: inherit;
1986+ text-decoration: none;
1987+
1988+ &:hover .subtask-title { text-decoration: underline; }
1989+}
1990+
1991+.subtask-mark {
1992+ display: flex;
1993+ color: var(--muted-soft);
1994+}
1995+
1996+.subtask-key {
1997+ font-family: var(--font-mono);
1998+ font-size: 11px;
1999+ color: var(--muted);
2000+}
2001+
2002+.subtask-title {
2003+ overflow: hidden;
2004+ text-overflow: ellipsis;
2005+ white-space: nowrap;
2006+}
2007+
2008+.subtask-status {
2009+ font-family: var(--font-mono);
2010+ font-size: 11px;
2011+ color: var(--muted-soft);
2012+}
2013+
2014+// A finished part stays legible and plainly out of the way. The tick and
2015+// the muted title each say it once; there is no strikethrough on top, which
2016+// only made the title harder to read and fought the hover underline.
2017+.subtask-row-done {
2018+ .subtask-title { color: var(--muted); }
1954 }2019 }
1955 2020
1956 .subtask-new {2021 .subtask-new {