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 {
946946 }
947947 }
948948
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+
949962 pub async fn tick(cx: &Cx) -> Result {
950963 view! {
951964 cx =>
@@ -1409,12 +1422,18 @@ async fn subtask_row(
14091422 }
14101423 view! {
14111424 cx =>
1412- <div class=(class!("dep-row", "subtask-row-done" if done))>
1413- if done { (glyph::tick(cx).await?) } else { (glyph::lock(cx).await?) }
1414- <a class="dep-key" href=(href.clone())>(part.task_key.clone())</a>
1415- <a class="dep-title" href=(href)>(part.title.clone())</a>
1425+ <div class=(class!("subtask-row", "subtask-row-done" if done))>
1426+ // One link, not two: the key and the title are the same target,
1427+ // so the whole of the row's text is the way in.
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>
14161435 <div class="spacer"></div>
1417- <span class="dep-note">(status)</span>
1436+ <span class="subtask-status">(status)</span>
14181437 <div class="avatars">
14191438 for face in faces { (face) }
14201439 </div>
@@ -1683,7 +1702,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
16831702 <div class="detail-headline">
16841703 if let Some(parent) = detail.parent.clone() {
16851704 <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>
16871708 </a>
16881709 }
16891710 <span class="detail-key">(detail.task_key.clone())</span>
crates/izlek-web/src/dropdown.rsmodified+48 -0
@@ -10,6 +10,33 @@
1010 //! visible trigger — same closed look as the select it replaces — and a
1111 //! `position: fixed` panel of option rows, portaled onto `<body>`, stands
1212 //! 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.
1340
1441 use topcoat::Result;
1542 use topcoat::context::Cx;
@@ -115,6 +142,8 @@ pub async fn dropdown_script(cx: &Cx) -> Result {
115142 panel.className = 'dd-panel';\
116143 panel.setAttribute('role', 'listbox');\
117144 panel.__ddTrigger = trigger;\
145+ trigger.__ddPanel = panel;\
146+ trigger.__ddSelect = select;\
118147 var allOpts = opts(select);\
119148 var search = null;\
120149 if (allOpts.length > 7 || select.hasAttribute('data-search')) {\
@@ -189,6 +218,25 @@ pub async fn dropdown_script(cx: &Cx) -> Result {
189218 if (trigger) { trigger.focus(); }\
190219 return true;\
191220 });\
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);\
192240 document.addEventListener('click', closeAll);\
193241 window.addEventListener('scroll', function (e) {\
194242 var t = e.target;\
crates/izlek-web/src/i18n.rsmodified+0 -3
@@ -289,7 +289,6 @@ pub enum Key {
289289 NoSubtasks,
290290 NewSubtask,
291291 AddSubtask,
292- PartOf,
293292 MakeAPart,
294293 ReleaseThisPart,
295294 ExistingTask,
@@ -844,8 +843,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
844843 (NewSubtask, Tr) => "Alt görev",
845844 (AddSubtask, En) => "Add",
846845 (AddSubtask, Tr) => "Ekle",
847- (PartOf, En) => "Part of",
848- (PartOf, Tr) => "Şunun parçası:",
849846 (MakeAPart, En) => "Take an existing task",
850847 (MakeAPart, Tr) => "Var olan görevi al",
851848 (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 {
262262 document.addEventListener('change', function (e) { \
263263 var control = e.target; \
264264 if (control.classList && control.classList.contains('file-upload-input')) { \
265- var name = control.closest('label').querySelector('.file-upload-name'); \
266- if (control.files && control.files[0]) { name.textContent = control.files[0].name; } \
265+ var label = control.closest('label'); \
266+ var name = label ? label.querySelector('.file-upload-name') : null; \
267+ if (name && control.files && control.files[0]) { name.textContent = control.files[0].name; } \
267268 control.form.requestSubmit(); \
268269 return; \
269270 } \
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() {
15171517 // The subtask kept its column: being taken in is not a move.
15181518 let page = app.get(&format!("/?task={loose}"), Some(&admin)).await;
15191519 let page = String::from_utf8_lossy(&page.bytes);
1520+ // The way back up: a link that names the whole, not a caption.
15201521 assert!(
1521- page.contains("Part of"),
1522- "the part does not name its whole"
1522+ page.contains("detail-parent") && page.contains(&format!("/?task={parent}")),
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"
15231528 );
15241529
15251530 let released = app
@@ -1700,6 +1705,62 @@ async fn a_parents_own_part_is_not_offered_as_a_blocker() {
17001705 );
17011706 }
17021707
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+
17031764 #[tokio::test]
17041765 async fn a_drop_decided_against_a_stale_board_is_refused() {
17051766 let app = App::open().await;
style/main.scssmodified+77 -12
@@ -1446,16 +1446,35 @@ img.avatar {
14461446 color: var(--muted-soft);
14471447 }
14481448
1449-// A subtask says whose part it is above its own key, so the page it opens on
1450-// still names the work it belongs to.
1449+// A subtask names the whole it belongs to, above its own key, and that name
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.
14511452 .detail-parent {
1452- display: block;
1453- font-family: var(--font-mono);
1453+ display: flex;
1454+ align-items: center;
1455+ gap: 6px;
14541456 font-size: 11px;
14551457 color: var(--muted);
14561458 text-decoration: none;
1459+ width: fit-content;
14571460
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;
14591478 }
14601479
14611480 .detail-title {
@@ -1943,14 +1962,60 @@ img.avatar {
19431962 font-size: 13px;
19441963 }
19451964
1946-// A finished part reads back the way a finished card does: still there,
1947-// still legible, plainly no longer in the way.
1948-.subtask-row-done {
1949- .dep-key,
1950- .dep-title,
1951- .dep-note { color: var(--muted-soft); }
1965+// A part is a lighter thing than a dependency: no box of its own, a rule
1966+// between rows instead, so a list of eight does not read as eight cards.
1967+.subtask-row {
1968+ display: flex;
1969+ align-items: center;
1970+ gap: 10px;
1971+ padding: 8px 4px;
1972+ border-bottom: 1px solid var(--border);
1973+ font-size: 13px;
19521974
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); }
19542019 }
19552020
19562021 .subtask-new {