Skip to content

Tighten the Projects topic sidebar and match topics exactly (#1474) - #1476

Open
jonfroehlich wants to merge 4 commits into
masterfrom
1474-project-filter-sidebar
Open

jonfroehlich wants to merge 4 commits into
masterfrom
1474-project-filter-sidebar

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

Fixes #1474

Implements "Direction A" (tightened sidebar) from the design review, plus the substring-match bug in the topic filter.

Changes

Template (project_listing.html)

  • <header class="projects-header"> (h1 + mobile <select>) moves above the two columns, so the h1 now precedes the filter's h2 in DOM order and the sidebar heading shares a hairline with "Active Projects".
  • Columns are now col-md-3 col-lg-2 / col-md-9 col-lg-10 (was col-md-2 at 992–1199px, which wrapped labels).
  • Heading text is "Topics"; it and the reset button sit together in a .filter-head row. The reset button keeps id="filter-reset-btn" and its aria-label, now reads "Clear" (no icon), and starts with the hidden attribute.
  • The per-button aria-describedby and filter-count-N ids are gone; the count is part of the button's name instead (53<span class="sr-only"> projects</span>). The JS never referenced those ids.

CSS (project-listing.css)

  • Plain right-aligned tabular counts (no pill), 30px row pitch, selected row is a --color-primary-light tint + 3px --color-primary left bar + medium weight (not colour-only).
  • :focus → :focus-visible with an inset (-2px) ring, so it isn't clipped by the sticky sidebar's scroller and doesn't stick after a mouse click.
  • "Clear" is a 13px underlined link in --color-link.
  • Sidebar borrows 8px of gutter (margin-left: -8px) so label text aligns with the h1; the stray trailing margin-top: 15px and padding-right are removed; .section-heading gets line-height: 22px so its hairline meets the filter heading's.
  • Mobile <select> is unchanged.

Bug fix: exact topic matching

  • display_project_snippet.html rendered data-project-keywords as space-joined umbrella short names, and project-listing-filter.js matched with indexOf, so "Design" also showed every "Maker/Design Tools" project (and short names with spaces were ambiguous). The card now renders a |-joined list, and the JS splits it and compares whole names (cardHasTopic). Both sides still use ProjectUmbrella.short_name, the key the view's umbrella map and the button/select values already use.
  • Caveat: a short name containing | would still break this; none do today.

Version: 2.35.6. (Another open PR may also bump the version; whichever merges second needs a re-bump.)

Contrast (computed from design-tokens.css values, WCAG 2.x formula)

Element Colours Ratio
Label #212121 on #fff 16.1:1
Count, "Topics" heading #595959 on #fff 7.0:1
Hover: label / count on #f5f5f5 14.8:1 / 6.4:1
Selected label + count #104d7a on #e8f4fc 7.9:1
"Clear" link #0d5a8c on #fff 7.4:1
Focus ring / selected bar (non-text) #1565A7 on #e8f4fc / #fff 5.4:1 / 6.1:1

The old selected state (white count on a translucent pill over #1565A7) was about 4.0:1.

Tests

  • New website/tests/test_project_listing_filter.py: a project in both "Design" and "Maker/Design Tools" renders both names whole; a "Maker/Design Tools"-only card does not contain "Design"; button data-filter values equal the card values; the space-joined format is gone; h1 precedes the filter h2; the count is inside the button's name; "Clear" starts hidden with its label. Four of these fail against the old snippet.
  • Full suite: python manage.py test website --settings=makeabilitylab.settings_test ran 836 tests: OK (8 skipped). It ran in a one-off makelab_image container mounting this branch, against a throwaway Postgres 16 container.

Still needed before merge

  • Before/after screenshots (CONTRIBUTING requires them for UI changes). I couldn't render the page in a headless browser in this session, so none are attached and the layout hasn't been checked visually. Things worth a look on the test server: the two hairlines line up; labels such as "Maker/Design Tools" don't wrap at 992–1199px (col-md-3) or at 1200px+ (col-lg-2, the tighter of the two); "Clear" appears in the heading row after a click; the mobile select is unchanged.
  • Pa11y run (--profile testing run --rm a11y); not run here.

🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5

jonfroehlich and others added 2 commits December 1, 2026 10:19
Direction A from the design review: the page header moves above both
columns, the sidebar is col-md-3/col-lg-2, "Topics" and a link-style
"Clear" share a heading row, counts are plain tabular numerals inside
each button's accessible name, the selected row is a tint plus a left
bar, and focus rings use :focus-visible with an inset offset.

Fix the filter matching "Design" inside "Maker/Design Tools": cards now
render their umbrella short names joined by "|", and the JS splits the
list and compares whole names. Add tests for both the markup and the
exact-match format. Bump to 2.35.6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The labels are ProjectUmbrella.short_name, which editors type freely, so a
lowercase entry rendered as "accessibility". text-transform: capitalize only
uppercases first letters, leaving "EdTech" and "AR" as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonfroehlich

Copy link
Copy Markdown
Member Author

Code review, round 1 of 2

Reviewed head 94b3bce1b3507ae54519479bc62bc2f3490dfaca against origin/master (6688489).

Summary: no blocking findings. Two should-fix items, two decisions for the maintainer, and some nits. The filter logic is correct and the PR body's numbers check out. Nothing was rendered in a browser (none was available to me either), so every layout statement below is derived from the CSS and real font metrics and is marked as such.

Should-fix

1. .section-heading { line-height: 22px } probably un-aligns the two hairlines it was added to align (derived, not rendered)

  • Before this PR the heading already had a 22px line: Bootstrap's h2 { line-height: 1.1 } × 20px. Because 1.1 is unitless, the nested .header-anchor (font-size: 0.7em; vertical-align: middle, base.css) inherited the factor and got a 15.4px box, which fits inside the line.
  • With an absolute 22px, the anchor inherits 22px too. A 22px box on a 14px font, aligned middle, sits about 1.9px lower than the parent's strut, so the line box grows. Using Raleway's actual metrics (ascender 940, descender -234, x-height 519, USE_TYPO_METRICS set) I get a line box of 22.00px before the PR and 23.87px after.
  • Result: both section headings get about 2px taller, and the "Active Projects" rule lands about 1.9px below the "Topics" rule (left: 8 + 22 + 8; right: 8 + 23.87 + 8).
  • Check in a browser at ≥992px: document.querySelector('#active-projects-heading').getBoundingClientRect().bottom - document.querySelector('.filter-head').getBoundingClientRect().bottom should be 0; I expect about 1.9.
  • Fix: drop the new declaration (the inherited 1.1 already yields 22px), or keep it and give .section-heading .header-anchor a line-height: 1.

2. The JavaScript half of the bug fix has no automated test

  • The new Django tests pin the server-side format only. Restoring substring matching in cardHasTopic (raw.indexOf(filterKeyword) !== -1) leaves all 7 new tests green, and so does changing KEYWORD_DELIMITER to ','. The first brings the issue's bug back in full; the second makes every multi-topic project unfilterable (confirmed by running the mutated file under Node, see below).
  • The repo already has the harness for this: website/tests/test_member_e2e.py (Playwright, skip-guarded) and the CI e2e job. A small e2e test on /projects/ (click "Design", assert a "Maker/Design Tools"-only card is hidden; repeat through the mobile <select>) would close the gap. The e2e job currently runs only website.tests.test_member_e2e, so the workflow command needs the new module added.
  • If that is out of scope, please say so in the PR body: at the moment "Tests" reads as if the fix is covered.

Needs a maintainer decision

3. col-md-9 drops the card grid from 3 columns to 2 for viewports of roughly 1013–1125px (derived, not rendered)

  • The grid is repeat(auto-fill, minmax(250px, 1fr)) with a 32px gap, so 3 columns need 814px. Main column width is 0.8333 × viewport − 30 before and 0.75 × viewport − 30 after, so the 3-column threshold moves from about 1013px to about 1125px.
  • Example, 1024px wide (iPad landscape): 3 cards of about 253px before, 2 cards of about 353px after, so the 86-project list gets about half again as long. At ≥1200px nothing changes.
  • col-md-3 is justified for the labels (at col-md-2 the longest label would still wrap below about 1115px even with the new, tighter row), so this is a trade-off, but the PR body doesn't mention it. Worth a screenshot at 1024px before deciding.

4. text-transform: capitalize on .filter-name (second commit, not described in the PR body)

  • It changes nothing today: all 14 topic names on the production page are already capitalised.
  • For future names it also rewrites ones that are deliberately lower-case first: "iOS" → "IOS", "eHealth" → "EHealth", "Internet of Things" → "Internet Of Things".
  • It applies to the desktop buttons only. The mobile <option> text and the live-region announcement use the raw name, so a lower-case entry would read differently on desktop and mobile.
  • If the goal is tidy labels, fixing the data (or a form clean) is more predictable than a display transform.

Nits

  • "1 projects". A topic with one visible project gets the accessible name "Topic 1 projects", and test_count_is_in_button_name pins that wording. {{ project_list|length|pluralize }} fixes it.
  • "Clear" now precedes the list in tab order and appears without announcement. A keyboard user who picks the 8th topic has to Shift+Tab back 8 stops to reach it. Pressing the selected topic again still clears the filter, so this is not a barrier; mentioning the button in the live-region text would help.
  • CSS comment overclaims: "Clear in the heading row so it can't scroll out of view". .filter-head is inside the scrolling nav, so it scrolls away with the list whenever the sidebar overflows (14 topics need about 471px; the sidebar is 100vh − 120px, so below about 590px of viewport height).
  • Stale comment in the FLEXBOX ROW HELPER block of project-listing.css: it still says the grid's parent is .col-md-10.
  • Hard-coded px (13px, 20px/22px line-heights, -8px) next to rem tokens. With a larger browser default font size the 14px-token labels grow but their 20px line-height doesn't.
  • Test gaps and brittleness: the mobile <option value> isn't asserted (lower-casing it leaves the tests green, and the mobile filter then matches nothing); test_clear_button_starts_hidden_with_name pins attribute order and whitespace, so a djlint reformat would fail it; the delimiter is defined in both the test and the JS with nothing asserting they agree.
  • Not from this PR, noted in passing: the token comments in design-tokens.css understate two ratios (--color-primary says 4.54:1, it is 6.08:1; --color-link says 5.48:1, it is 7.35:1).

PR-body claims

Claim Result
Contrast table (all nine values) Confirmed by recomputing from the token hex values: 16.10, 7.00, 14.77, 6.42, 7.94, 7.35, 5.44, 6.08; old pill resolves to #4484b9, white on it 4.00. Also fine but not listed: "Clear" hover #083854 on white 12.32; focus ring on the hover background 5.58.
"The JS never referenced those ids" Confirmed. At base, filter-count-N appears only in the template.
No other consumer of data-project-keywords Confirmed. The landing page and member page render the same snippet, but only project-listing-filter.js reads the attribute. The stylesheet is also loaded on those two pages, but neither has a .section-heading element, so the line-height change is confined to the Projects page.
"Four of these fail against the old snippet" Confirmed (mutation M1).
"836 tests: OK (8 skipped)" Confirmed: Ran 836 tests in 563.327s, OK (skipped=8) at head, throwaway Postgres 16 + makelab_image. No failures, so no base re-run was needed.
| caveat: "none do today" Confirmed against the 14 names on the production page. The only substring overlap there is "Design" in "Maker/Design Tools".
Labels no longer wrap Likely (measured, not rendered). FreeType widths for Roboto 400/500: the longest label, "Maker/Design Tools", is 125.4px selected; room is 136–139px at 1200px+ (11–14px slack) and 183px+ at 992–1199px. The same method reproduces the issue's "Urban Informatics wraps by about 1.5px" on the old layout (112.1px vs 110.3px).
:focus → :focus-visible stops the ring after a mouse click Confirmed by cascade: the old .filter-btn:focus tied the global :focus:not(:focus-visible) on specificity and won on order.
Mobile <select> unchanged Confirmed: same markup, moved with the header; its CSS is untouched.

Behaviour check of the JavaScript (Node, hand-rolled DOM stub, real file)

20 assertions pass at head: exact match from the desktop buttons and from the mobile <select> (including names with a space and "AR" vs "Art"), toggle-off, "Clear" (shows all, hides itself, moves focus to the first topic), aria-pressed sync, hidden toggling, empty-state messages, live-region text. The base file fails the "Design" cases exactly as the issue describes.

Mutation results (new test module, 7 tests)

Mutation Result
M1 snippet back to space-joined killed (4 fail)
M2 JS back to substring indexOf survives
M3 JS delimiter ',' survives
M4 snippet delimiter , killed (2)
M5 button data-filter lower-cased killed (1)
M6 mobile <option value> lower-cased survives
M7 "Clear" without hidden killed (1)
M8 count back to aria-describedby + ids killed (1)
M9 h1 after the filter h2 killed (1)
M10 drop the sr-only " projects" killed (1)
M11 trailing delimiter in the snippet killed (3)
M12 M1 + M2 together (the original bug) killed (4), by the snippet half only

No CSS is under test, which is normal for this repo.

Still unverified

  • Everything visual: hairline alignment (finding 1), label wrapping, the inset focus ring on the 2px-padded "Clear" link, the 3 → 2 column change (finding 3). Screenshots at 1024, 1199 and 1200px would settle all of them.
  • Pa11y on the redesigned buttons. The CI a11y job is not evidence here: its seeded database has no topics, so /projects/ rendered an empty <ul class="filter-list"> and no filter button was scanned. (Same 20 errors on master and on this head; only the h1 selector path differs.) A local run against real data is still needed, as the PR body says.
  • Stale-cache window (FYI, derived). Static files are served unhashed with no Cache-Control, so a returning visitor can briefly get old CSS or JS with the new HTML. Old JS + new HTML still filters (with the old substring behaviour, confirmed in Node). Old CSS + new HTML should show "Clear" permanently, because the old display: flex beats the hidden attribute. Both heal on refresh.

🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2

jonfroehlich and others added 2 commits December 1, 2026 16:15
Review round 1 on PR 1476 found the JS half of the exact-match fix had no
test: substring matching, a ',' delimiter, or a lower-cased mobile
<option value> all left the suite green. test_project_listing_e2e.py runs
project-listing-filter.js under Playwright (desktop buttons, mobile
<select>, Clear) and kills all three mutations; the CI e2e job now runs it.

It also pins the hairline alignment the review predicted would break:
.section-heading's absolute 22px line-height was inherited by the
.header-anchor icon, whose middle-aligned 22px box grew the line box and
dropped the "Active Projects" rule 1.81px below the "Topics" rule
(measured at 1024px). The anchor now gets line-height: 1; delta is 0 at
992, 1024, 1199, 1200 and 1440px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The count's accessible name now pluralizes ("AR 1 project"); tests pin
  both "1 project" and "2 projects".
- CSS comments: "Clear" does scroll away with the heading row when the
  sidebar overflows; the grid's parent is .col-md-9 .col-lg-10, not
  .col-md-10.
- The "Clear" markup test uses assertInHTML instead of a regex that pinned
  attribute order and whitespace.
- New assertions: the mobile <option value>s equal the buttons'
  data-filter values, and the JS KEYWORD_DELIMITER equals the one the
  tests split the template output on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Projects page: tighten topic filter sidebar (AA contrast, wrapping) and fix substring filter match

1 participant