Build the pill row eagerly, so a hover is a read the row records
The pills are the one place in this file that reads a ratom inside a `for` body rather than above it: each asks `hovering-reaction?` whether the card belongs to it. A read that happens while a lazy seq is realised somewhere other than the render is a read the component never records, so nothing subscribed, and the row went on showing what it showed before the pointer arrived — the card never appeared however long you rested on a pill. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
be8da43 parent: eb6778a modified
src/frq/app.clj +10 -2 | @@ -563,7 +563,15 @@ | ||
| 563 | 563 | Twemoji pack, in colour, where a label gets whatever the text font has." |
| 564 | 564 | [channel m] |
| 565 | 565 | (let [reactions (:reactions m)] |
| 566 | - [:hbox {:key :pills :spacing (chip-gap)} | |
| 566 | + ;; `into` and not a lazy `for` inside the vector. The pills read | |
| 567 | + ;; `hovering-reaction?` — a ratom — and a ratom read while a lazy seq is | |
| 568 | + ;; being realised somewhere other than the render is a read the component | |
| 569 | + ;; never records, so the row went on showing what it showed before the | |
| 570 | + ;; pointer arrived. It is the one place in this file whose ratom read is | |
| 571 | + ;; inside the `for` body rather than above it, which is why it is the one | |
| 572 | + ;; place that needs this. | |
| 573 | + (into | |
| 574 | + [:hbox {:key :pills :spacing (chip-gap)}] | |
| 567 | 575 | (for [emoji (sort (keys reactions))] |
| 568 | 576 | [:reaction (cond-> {:key emoji |
| 569 | 577 | :emoji emoji |
| @@ -581,7 +589,7 @@ | ||
| 581 | 589 | ;; whatever children the node has, and a channel's worth of unseen |
| 582 | 590 | ;; lists is a tree nobody looks at. |
| 583 | 591 | (when (and (platform/desktop?) (s/hovering-reaction? (:id m) emoji)) |
| 584 | - [reactor-card emoji (get reactions emoji)])])])) | |
| 592 | + [reactor-card emoji (get reactions emoji)])])))) | |
| 585 | 593 | |
| 586 | 594 | (def ^:private picker-columns |
| 587 | 595 | "Emoji to a row, at the picker's own size. Narrow enough that the grid fits a |
| @@ -563,7 +563,15 @@ | |||
| 563 | Twemoji pack, in colour, where a label gets whatever the text font has." | 563 | Twemoji pack, in colour, where a label gets whatever the text font has." |
| 564 | [channel m] | 564 | [channel m] |
| 565 | (let [reactions (:reactions m)] | 565 | (let [reactions (:reactions m)] |
| 566 | - [:hbox {:key :pills :spacing (chip-gap)} | 566 | + ;; `into` and not a lazy `for` inside the vector. The pills read |
| 567 | + ;; `hovering-reaction?` — a ratom — and a ratom read while a lazy seq is | ||
| 568 | + ;; being realised somewhere other than the render is a read the component | ||
| 569 | + ;; never records, so the row went on showing what it showed before the | ||
| 570 | + ;; pointer arrived. It is the one place in this file whose ratom read is | ||
| 571 | + ;; inside the `for` body rather than above it, which is why it is the one | ||
| 572 | + ;; place that needs this. | ||
| 573 | + (into | ||
| 574 | + [:hbox {:key :pills :spacing (chip-gap)}] | ||
| 567 | (for [emoji (sort (keys reactions))] | 575 | (for [emoji (sort (keys reactions))] |
| 568 | [:reaction (cond-> {:key emoji | 576 | [:reaction (cond-> {:key emoji |
| 569 | :emoji emoji | 577 | :emoji emoji |
| @@ -581,7 +589,7 @@ | |||
| 581 | ;; whatever children the node has, and a channel's worth of unseen | 589 | ;; whatever children the node has, and a channel's worth of unseen |
| 582 | ;; lists is a tree nobody looks at. | 590 | ;; lists is a tree nobody looks at. |
| 583 | (when (and (platform/desktop?) (s/hovering-reaction? (:id m) emoji)) | 591 | (when (and (platform/desktop?) (s/hovering-reaction? (:id m) emoji)) |
| 584 | - [reactor-card emoji (get reactions emoji)])])])) | 592 | + [reactor-card emoji (get reactions emoji)])])))) |
| 585 | 593 | ||
| 586 | (def ^:private picker-columns | 594 | (def ^:private picker-columns |
| 587 | "Emoji to a row, at the picker's own size. Narrow enough that the grid fits a | 595 | "Emoji to a row, at the picker's own size. Narrow enough that the grid fits a |