Skip to content

SF2.0[fix]: Fix funky focus outline#3077

Open
lvachon1 wants to merge 1 commit intomainfrom
lev/fix/sf/funky_focus
Open

SF2.0[fix]: Fix funky focus outline#3077
lvachon1 wants to merge 1 commit intomainfrom
lev/fix/sf/funky_focus

Conversation

@lvachon1
Copy link
Copy Markdown
Contributor

@lvachon1 lvachon1 commented Apr 2, 2026

Scope

Asana Ticket: 📅🔎 Fix funky focus outline

Implementation

Adjusted schedule finder logic so it wouldn't render an empty additional_info section if additional_info was an empty list.
Adjusted lined_list_item CSS to overlap the line a little bit less so that the focus outline isn't as wonky. Unfortunately, getting rid of the focus outline wonk entirely brings back the little gap issue.

Screenshots

🚇 Subway

Screenshot 2026-04-02 at 11 32 24 AM Screenshot 2026-04-02 at 11 32 17 AM

🚂 Commuter Rail

Screenshot 2026-04-02 at 11 30 59 AM Screenshot 2026-04-02 at 11 30 49 AM

🚌 Bus

Screenshot 2026-04-02 at 11 30 31 AM Screenshot 2026-04-02 at 11 30 26 AM

How to test

http://localhost:4001/departures/?route_id=71&direction_id=1&stop_id=2052

Check out various lines and modes and observe that the focus outlines look much better than before.


… info section if additional info was an empty list. Adjusted lined list item CSS to overlap the line a little bit less so that the focus outline isn't as wonky. Unfortunately, getting rid of the focus outline wonk entirely brings back the little gap issue.
@lvachon1 lvachon1 requested a review from a team as a code owner April 2, 2026 15:46
@lvachon1 lvachon1 requested a review from joshlarson April 2, 2026 15:46
class="flex items-center gap-2"
>
<div class="h-0 invisible shrink-0">
<RouteComponents.route_icon size="small" route={@route} />
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have an invisible icon here? This was the root element of the problem and the fact that it was rendering even with an empty additional_info. Can we remove it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invisible icon makes it so that Train 991 • Track 1 (Outbound) is aligned with Stoughton in the screenshot below.

Image

I don't mean that that's the right way to do it 😅 - just that that's what I came up with to solve that problem when I originally built this!

I'm guessing that the Correct™ answer here involves using a CSS grid, but I vaguely remember struggling with line-wrapping - with the grid either pre-emptively wrapping all the lines, or refusing to line-wrap at all ever, even if the screen was narrow.

Image (This is pretty much the line-wrapping we want, which we got for free with flex)

I'm all for trying again to get this right though - either as part of this PR or a follow-up!

@lvachon1 lvachon1 changed the title Fix funky focus outline SF2.0[fix]: Fix funky focus outline Apr 2, 2026
class="flex items-center gap-2"
>
<div class="h-0 invisible shrink-0">
<RouteComponents.route_icon size="small" route={@route} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invisible icon makes it so that Train 991 • Track 1 (Outbound) is aligned with Stoughton in the screenshot below.

Image

I don't mean that that's the right way to do it 😅 - just that that's what I came up with to solve that problem when I originally built this!

I'm guessing that the Correct™ answer here involves using a CSS grid, but I vaguely remember struggling with line-wrapping - with the grid either pre-emptively wrapping all the lines, or refusing to line-wrap at all ever, even if the screen was narrow.

Image (This is pretty much the line-wrapping we want, which we got for free with flex)

I'm all for trying again to get this right though - either as part of this PR or a follow-up!

<div
class="w-6 shrink-0 self-stretch flex justify-center relative"
style="margin-block: calc(-1 * (var(--spacing-3) + 1px));"
style="margin-block: calc(-1 * (var(--spacing-3) + 0.5px));"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually makes the gap issue more pronounced, and has it show up for smaller font sizes.

This is with a font size of 24px, where the gaps show up (quite small, but very visible if you view the image at full size) on this branch, but not on prod. On prod, the gaps only show up for font sizes >= 40px.
Image


The root cause here, definitely of the gap issue, and maybe of the funky outline as well, is that we're adding a value in px to a value in rem, which usually leads to funky results. (There are very rare circumstances in which it's the right call, but I wouldn't be surprised if that basically never happens on dotcom.)

I bet we could solve the gap issue and make the outline be completely non-funky by changing the 0.5px to a value in rem instead. (0.03125rem is the same as 0.5px at the 16px font size, but you may be able to get to fully non-funky by fiddling with the exact value).

Copy link
Copy Markdown
Contributor

@joshlarson joshlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts on px versus rem, and some historical context for my initial (probably not very good) attempt to align things!

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.

2 participants