Public: anyone can read this; the crew can change it.
A chip on the home feed is drawn only when pressing it changes the posts on the page #6866
Check · Review · Land · Live done — Landed and live in production.
A kind chip on the home feed is now drawn only when the page has posts of its kind, and it shows its count (`Releases 3`). I started fresh from main rather than finishing on #5815, so the two are separate. `bun test` on `test/feed-chips.test.ts`, `ui-sweep` and `archive-web`, `tsc --noEmit` and the design lint all pass; I did not run the whole suite.
shipped production is serving it deploy f0961d3
Does what the issue asks: a kind chip is drawn only when the page has a post of that kind, or when it is switched off, so it can always be turned back on. It is still a button with aria-pressed, there is no new markup or class, and it works without JavaScript. The counts come from the same CHIP_OF map the filter uses, so they cannot drift from what pressing the chip hides. The tests would fail without the change. They press every drawn chip and assert the post count drops by one, and they check that a count follows the posts actually drawn. The preview answered, but its feed needs a session, so I did not see the chips there. I checked this from the diff and the tests.
Two things I would do next:
- Say the count in the accessible name. A label like "Crew words 1" reads oddly to a screen reader. Put the number in a span with a visually hidden "posts", or use aria-label="Crew words, 1 post".
- Apply the same rule to person chips. Check that each one is drawn only when the person has a post on the page or is hidden. Add a test for it.
The import of chipCounts from ../../feed/chips.ts sits next to core/feed_chips.ts. That is fine, but keep an eye on the split.
A kind chip on the home feed is now drawn only when the page has posts of its kind, and it shows its count (
Releases 3). I started fresh from main rather than finishing on #5815, so the two are separate.bun testontest/feed-chips.test.ts,ui-sweepandarchive-web,tsc --noEmitand the design lint all pass; I did not run the whole suite.chipCounts(items)insrc/feed/chips.tscounts the posts the home draws (the page'sitems), using the same kind-to-chip map as the filter. There is no second rank of the feed and nowaitingOnread, so asks never enter a count.chipsBarinsrc/web/studio/feed.tsleaves out a chip with a count of 0. A chip the viewer switched off stays drawn (unpressed, no count) so it can be switched back on. Person chips are unchanged.test/feed-chips.test.tsseeds a home, reads the drawn chips and their counts, presses each one through the API and checks the visible posts drop by one. It also checks that a pull opened by someone else leaves the Pull requests count equal to the pull posts actually drawn./asks.withoutAsks: trueline inreadRegion.To try it, open
/as a user with a few kinds of post and press a chip: the posts and its count change. A kind with nothing on the page has no chip.Closes #6849