forge
Explore
Log in

Don't you dare go Hollow

Three defects the browser found that the compiler could not

Browse files at this commit

7fd5ec2cebf01d678ef766cb16308e3b78e9b88eAhmet Kaan GümüşParent: 9b4b86e
  • fix
    • three defects the browser found that the compiler could not
Show full message
🐛 fix(detail): three defects the browser found that the compiler could not

Driving the modal in a real Firefox turned up three things eighty-four
green tests did not.

Posting a comment closed the modal. `board.refetch()` re-suspends the
board's `Suspense`, which tears down and rebuilds `BoardScreen`, and the
`opened` signal that named the open card was owned by that component —
so it was reborn `None` on every save. It now lives in `Board`, above
the suspense boundary, and is passed down.

Escape did nothing. The keydown handler was bound to the modal element
and relied on `autofocus` to put focus there; Firefox ignores
`autofocus` on an element inserted after the click, so focus stayed on
the card behind the scrim and the modal never heard the key. It is a
`window_event_listener` now, removed on cleanup.

A refused call printed its sentence at the foot of the modal, below the
activity trail — off-screen from the button that was pressed. Each form
renders its own refusal directly beneath itself.

Also from the artboard comparison: the small-caps section labels are
IBM Plex Mono in the design and were rendering in the body face at
weight 600. And two doc comments in the store trait were transposed.

Verified live at 1280x720: screenshots in
~/.cache/vh-runs/20260826-094349-MzMIdQ (comment2, esc2, cycle-inline,
mono-labels). Suites: 15 core unit, 58 store, 11 http, all passing.
crates/dizey-core/src/store/mod.rsmodified+2 -2
@@ -341,12 +341,12 @@ pub trait Store: BoardReads + DetailReads + 'static {
341341 at: OffsetDateTime,
342342 ) -> Result<Vec<String>>;
343343
344- /// Appends one line to a task's activity trail. `actor_id` is `None` when
345- /// the system did it rather than a person.
346344 /// What a delete would take with it, for the confirmation step. Reads
347345 /// only; nothing here writes.
348346 async fn deletion_cost(&self, task_id: &str) -> Result<Option<DeletionCost>>;
349347
348+ /// Appends one line to a task's activity trail. `actor_id` is `None` when
349+ /// the system did it rather than a person.
350350 async fn record_activity(
351351 &self,
352352 task_id: &str,
crates/dizey-web/src/board.rsmodified+13 -3
@@ -120,6 +120,11 @@ impl Filter {
120120 #[component]
121121 pub fn Board() -> impl IntoView {
122122 let board = Resource::new(|| (), |_| async move { current_board().await });
123+ // Which card is open in the detail modal, if any. It lives out here, above
124+ // the suspense boundary: a refetch rebuilds `BoardScreen` from scratch, and
125+ // a signal owned by that component would be born empty again — closing the
126+ // modal every time something inside it saved.
127+ let opened = RwSignal::new(None::<String>);
123128
124129 view! {
125130 <Suspense fallback=|| {
@@ -128,7 +133,13 @@ pub fn Board() -> impl IntoView {
128133 {move || Suspend::new(async move {
129134 match board.await {
130135 Ok(Ok(snapshot)) => {
131- view! { <BoardScreen snapshot=snapshot on_change=move || board.refetch()/> }
136+ view! {
137+ <BoardScreen
138+ snapshot=snapshot
139+ opened=opened
140+ on_change=move || board.refetch()
141+ />
142+ }
132143 .into_any()
133144 }
134145 Ok(Err(refusal)) => {
@@ -156,14 +167,13 @@ pub fn Board() -> impl IntoView {
156167 #[component]
157168 fn BoardScreen(
158169 snapshot: BoardSnapshot,
170+ opened: RwSignal<Option<String>>,
159171 on_change: impl Fn() + Copy + Send + Sync + 'static,
160172 ) -> impl IntoView {
161173 let BoardSnapshot { view, me, today } = snapshot;
162174 let filter = RwSignal::new(Filter::All);
163175 // Which column has its composer open, if any.
164176 let composing = RwSignal::new(None::<String>);
165- // Which card is open in the detail modal, if any.
166- let opened = RwSignal::new(None::<String>);
167177 let may_write = me.role.can_write_tasks();
168178 let my_id = StoredValue::new(me.id.clone());
169179
crates/dizey-web/src/detail.rsmodified+42 -28
@@ -432,6 +432,29 @@ pub async fn delete_task(task_id: String) -> Result<Option<Refusal>, ServerFnErr
432432
433433 // -- the screen -------------------------------------------------------------
434434
435+/// Whatever a refused call said, rendered where the form that asked for it is.
436+/// A refusal shown at the far end of a scrolling modal is a refusal nobody
437+/// reads: the person clicked "Link a task" and the sentence has to land under
438+/// that button, not under the activity trail.
439+fn refused<S>(action: ServerAction<S>) -> impl IntoView
440+where
441+ S: leptos::server_fn::ServerFn<Output = Option<Refusal>> + Send + Sync + Clone + 'static,
442+ S::Error: Clone + Send + Sync + 'static,
443+{
444+ move || {
445+ action
446+ .value()
447+ .get()
448+ .and_then(|answer| match answer {
449+ Ok(refusal) => refusal,
450+ // The call never arrived, which is not the person's mistake and
451+ // is not a sentence about their task.
452+ Err(_) => Some(Refusal::Unavailable),
453+ })
454+ .map(|refusal| view! { <p class="modal-problem">{refusal.message()}</p> })
455+ }
456+}
457+
435458 /// The modal. `esc` closes it, as the artboard's chip says.
436459 #[component]
437460 pub fn TaskDetailModal(
@@ -451,27 +474,22 @@ pub fn TaskDetailModal(
451474 on_change();
452475 };
453476
454- view! {
455- <div
456- class="modal-scrim"
457- on:click=move |_| on_close()
458- on:keydown=move |event| {
459- if event.key() == "Escape" {
460- on_close();
461- }
477+ // Escape listens on the window, not on the modal. The modal is inserted
478+ // after the click that opened it, so focus is still on the card behind the
479+ // scrim and a listener bound to this element would never hear the key.
480+ #[cfg(feature = "hydrate")]
481+ {
482+ let handle = window_event_listener(leptos::ev::keydown, move |event| {
483+ if event.key() == "Escape" {
484+ on_close();
462485 }
463- >
464- <div
465- class="modal"
466- tabindex="-1"
467- autofocus
468- on:click=move |event| event.stop_propagation()
469- on:keydown=move |event| {
470- if event.key() == "Escape" {
471- on_close();
472- }
473- }
474- >
486+ });
487+ on_cleanup(move || handle.remove());
488+ }
489+
490+ view! {
491+ <div class="modal-scrim" on:click=move |_| on_close()>
492+ <div class="modal" tabindex="-1" on:click=move |event| event.stop_propagation()>
475493 <Suspense fallback=|| {
476494 view! { <div class="modal-loading"></div> }
477495 }>
@@ -557,13 +575,6 @@ fn DetailScreen(
557575 }
558576 });
559577
560- let problem = move || {
561- [save.value(), comment.value(), link.value(), remove.value()]
562- .into_iter()
563- .find_map(|value| value.get().and_then(|answer| answer.ok().flatten()))
564- .map(|refusal| view! { <p class="modal-problem">{refusal.message()}</p> })
565- };
566-
567578 view! {
568579 <header class="detail-head">
569580 <span class="detail-key">{task_key}</span>
@@ -656,6 +667,7 @@ fn DetailScreen(
656667 "Save"
657668 </button>
658669 </div>
670+ {refused(save)}
659671 }
660672 })}
661673 </ActionForm>
@@ -735,6 +747,7 @@ fn DetailScreen(
735747 "Link a task"
736748 </button>
737749 </ActionForm>
750+ {refused(link)}
738751 }
739752 })}
740753 </section>
@@ -770,6 +783,7 @@ fn DetailScreen(
770783 </button>
771784 </div>
772785 </ActionForm>
786+ {refused(comment)}
773787 }
774788 })}
775789 </section>
@@ -796,7 +810,7 @@ fn DetailScreen(
796810 .collect_view()}
797811 </section>
798812
799- {problem}
813+ {refused(remove)}
800814
801815 {move || {
802816 ask.value()
style/main.scssmodified+3 -3
@@ -712,8 +712,8 @@ a {
712712 }
713713
714714 .detail-label {
715+ font-family: var(--font-mono);
715716 font-size: 10px;
716- font-weight: 600;
717717 letter-spacing: 0.08em;
718718 color: var(--muted-soft);
719719 }
@@ -852,9 +852,9 @@ a {
852852 }
853853
854854 .dep-heading {
855+ font-family: var(--font-mono);
855856 font-size: 10px;
856- font-weight: 600;
857- letter-spacing: 0.08em;
857+ letter-spacing: 0.06em;
858858 color: var(--muted-soft);
859859 }
860860