Spaces:
Running
fix(frontend): save button did nothing — arXiv ids break `#id` CSS selectors
Browse filesRegression from the feed redesign. The Save button targeted
`#actions-{{ pid }}`, but every arXiv id contains a dot, and in a CSS selector
a dot starts a class token:
#actions-1706.03762 -> id="actions-1706" AND class="03762"
A class token also cannot begin with a digit, so this is not a near miss —
querySelector raises SelectorSyntaxError ("Malformed class selector at
position 13", confirmed against a real CSS engine). htmx could not resolve the
target, so the swap never ran and clicking Save appeared to do nothing.
The POST itself was always fine; only the UI never updated.
Restores the attribute-selector form the pre-redesign code used deliberately,
now with a comment explaining why so it does not regress again. Same bug and
same fix in the onboarding seed picker, which was silently broken for every
seed save.
Verified: 12/12 save targets in a live feed resolve to exactly one element;
save round-trip returns the Saved state, keeps "Why this?", and writes the
interaction row.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@@ -60,9 +60,17 @@
|
|
| 60 |
data-paper-id="{{ pid }}"
|
| 61 |
data-vals='{{ _vals | tojson }}'>Remove</button>
|
| 62 |
{% else %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
<button type="button" class="btn btn-sm btn-save"
|
| 64 |
hx-post="/api/papers/{{ pid }}/save"
|
| 65 |
-
hx-target="
|
| 66 |
hx-swap="innerHTML"
|
| 67 |
hx-vals='{{ _vals | tojson }}'>
|
| 68 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"
|
|
|
|
| 60 |
data-paper-id="{{ pid }}"
|
| 61 |
data-vals='{{ _vals | tojson }}'>Remove</button>
|
| 62 |
{% else %}
|
| 63 |
+
{#
|
| 64 |
+
The target MUST be the attribute-selector form, not "#actions-{{ pid }}".
|
| 65 |
+
Every arXiv id contains a dot (1706.03762), and in a CSS selector that dot
|
| 66 |
+
starts a class token — so "#actions-1706.03762" parses as
|
| 67 |
+
id="actions-1706" AND class="03762", which matches nothing. A class token
|
| 68 |
+
also cannot begin with a digit, so querySelector raises a SyntaxError
|
| 69 |
+
rather than merely missing. [id='…'] compares the literal string.
|
| 70 |
+
#}
|
| 71 |
<button type="button" class="btn btn-sm btn-save"
|
| 72 |
hx-post="/api/papers/{{ pid }}/save"
|
| 73 |
+
hx-target="[id='actions-{{ pid }}']"
|
| 74 |
hx-swap="innerHTML"
|
| 75 |
hx-vals='{{ _vals | tojson }}'>
|
| 76 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"
|
|
@@ -18,7 +18,9 @@
|
|
| 18 |
</div>
|
| 19 |
<button type="button" class="btn btn-sm btn-save"
|
| 20 |
hx-post="/api/papers/{{ paper.arxiv_id }}/save"
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
hx-swap="outerHTML"
|
| 23 |
hx-vals='{"source": "onboarding", "position": {{ loop.index0 }}}'
|
| 24 |
onclick="if (window.bumpSeedCount) window.bumpSeedCount()">Save</button>
|
|
|
|
| 18 |
</div>
|
| 19 |
<button type="button" class="btn btn-sm btn-save"
|
| 20 |
hx-post="/api/papers/{{ paper.arxiv_id }}/save"
|
| 21 |
+
{# Attribute selector, not "#seed-paper-…": the dot in an arXiv
|
| 22 |
+
id would be read as a CSS class token. See action_buttons.html. #}
|
| 23 |
+
hx-target="[id='seed-paper-{{ paper.arxiv_id }}']"
|
| 24 |
hx-swap="outerHTML"
|
| 25 |
hx-vals='{"source": "onboarding", "position": {{ loop.index0 }}}'
|
| 26 |
onclick="if (window.bumpSeedCount) window.bumpSeedCount()">Save</button>
|