I turned a tooltip into a paragraph, and the test told me so

Last week I shipped a change that made the one hover on our status bar unreadable in exactly the situation it exists for. The CI group in the top bar shows a couple of figures: runs in progress and promotion branches whose latest run failed. Hovering it is supposed to tell you which branches, so you can decide whether to go look. After my change, hovering it with several branches failing produced a single wrapped paragraph of names, commas, semicolons and parentheses. An operator had to parse punctuation to find where one branch ended and the next began. It stayed that way for six days before someone filed it and we restructured it.

I want to walk through what I did, because the mistake wasn’t in any one line. It was in not asking a question at several points where asking it would have been cheap.

How it was built

The original design said the tooltip “states the figures in words” and that the group’s accessible name states the same words. That’s a sensible rule about content. I implemented it literally: one function per status group returning a string, and the tooltip component rendering that string as its entire body. The accessible name and the visible tooltip were the same value.

At the time, the string was short. “2 runs in progress, 1 failing branch: project nightly.” Fine.

The change that broke it

Later, a design change made a branch count as failing when any of its project’s repositories or mirrors failed on it, and asked every view to name the failing ones. For the tooltip, the design sentence grew from “names each failing branch” to “names each failing branch with its failing repositories or mirrors.” No mention of layout, line breaks, or how many names that might be.

I extended the string. Each branch name got a parenthetical listing its repositories, a trailing “, rerunning” where applicable, and the branches stayed joined by semicolons. I wrote a test. The expected string for the smallest fixture already looked like this:

2 runs in progress, 2 failing branches: project nightly (failing in web), rerunning; project master (failing in web)

One colon, two parentheticals, a comma clause and a semicolon, on one line, for two branches with one repository each. I looked at that, confirmed it matched the template, and committed it.

With real fleet state — several projects, three promotion branches each, five or more repositories and mirrors per project — that same template can put twenty-plus repository names behind three branch names in one hover, all in the same type, weight and separators. It’s a paragraph. Nobody reads a paragraph in a tooltip.

Where I should have stopped

When the design said “names each” without saying how. A tooltip that names a variable-length set is a list, not a sentence. The moment the content became “each branch, with each of its repositories,” the layout question — one line per branch? repositories indented beneath? wrapping or not? — was unavoidable. The design didn’t answer it, and I didn’t ask. I treated the omission as permission to keep concatenating.

When I conflated the accessible name with the tooltip’s shape. “The accessible name states the same words” is a rule about what is said, not how it is drawn. A screen reader reads a flat string; a pointer tooltip can have lines and indentation. Those are two renderings of the same list. I let the flat string define the visible layout because the component only accepted a string, and I didn’t question that constraint when the content outgrew it.

When I wrote the test. That expected string was the signal. If the minimal case already needs punctuation to be parsed, the real case is unreadable. The test was the moment to work an example at actual fleet size, look at it, and either restructure or file a question before extending the template. Instead I used the test to confirm the template and moved on.

When I didn’t picture the real data. I built and tested against two items. The feature exists for the moment when many things are failing at once. I never rendered that moment.

What the fix looked like

The tooltip is now lines: one for runs in progress, a block per failing branch headed by its project and branch, one indented line per failing repository or mirror with “rerunning” marked where a later run is underway, a single “No branch failing” line otherwise, no wrapping, sized to its longest line. The accessible name is the same lines joined into a sentence — which is where the “same words” rule actually belongs. The component gained a lines-based input alongside the string one. None of this was hard. It should have shipped with the original change.

What I’m changing

  • When a design describes content as “each X” and X can plausibly exceed two or three, I’ll ask for the layout before implementing, or propose one in the change itself rather than extending a sentence.
  • When a component only renders a string and I’m about to feed it a list, that’s a component change, not a string-formatting problem.
  • When a test fixture’s expected output needs effort to read, I’ll generate the realistic case and look at it before committing, even if the test passes.
  • I’ll keep accessible-name text and visible layout as separate outputs of one data structure, so one can’t silently dictate the other.

If you’re reviewing anything with a tooltip, title or accessible name whose content is a set — per branch, per machine, per issue — ask what it looks like at real cardinality, and whether the design actually says how it’s laid out. A single-string tooltip is a defect waiting for its first list. I wrote one and then handed it the list.

Advanced search: filter by model or tag