Repository navigation
Responsive / overflowing tables - #1310
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
One edge case I was unable to resolve is the lack of a border if a table is overflowing without a sticky final cell. I can think of a potential solution, but it's fairly involved and has ramifications for selected rows. Based on the complexity, for now I think we can omit and see if it crops up. Fixed the conflicts with main, and ready for review and merging whenever you find time to peruse through the PR. |
|
I think the no border problem is fine, I agree it's better to do nothing. If anything it subtly indicates there's more. Reviewing now. I noticed two bugs just now, trying to investigate. Bug 1: Gradient visible outside table in scroll bar areaThe gradient one only appears when I reload the window at a size that makes the table already squished at page load time. If I reload the window with it wide and then shrink it down, the errant gradient does not appear (it also does not appear in the cells, where it is supposed to). I figured out this is due to the throttling and the fact that the event listener that toggles overflowing state is only on scroll, not on window resize. Adding it on resize gets the bug to show up on resize in addition to new pageload, though the throttling seems to introduce subtle bugs, for example if you resize the window slowly enough it seems to somehow get through without making the grading thing show up. FirefoxExtra bit of border + black gradient is visible in the corner outside the table. It's very hard to see, I have to really squint. SafariExtra bit of border, but no black gradient thing. Bug 2: extra bit of borderThe pesky border belongs to the date cell. Was hoping for a z-index fix but it seems like that won't work. One hack would be to round the corner in question, but only when the table is |
|
The simplest things are always the hardest...pushed fixes for both. |
|
|
||
| const { current } = ref | ||
| current.addEventListener('scroll', handleScroll) | ||
| return () => current.removeEventListener('scroll', handleScroll) |
There was a problem hiding this comment.
Unless you add a resize listener too, you only get the gradient showing up if the table is already overflowing at pageload. Seems ok? When I try it, I don't see any jankiness — seems like throttle is doing its job.
current.addEventListener('scroll', handleScroll)
window.addEventListener('resize', handleScroll)
return () => {
current.removeEventListener('scroll', handleScroll)
window.removeEventListener('resize', handleScroll)
}
david-crespo
left a comment
There was a problem hiding this comment.
Looks great. Really difficult stuff. Good to merge pending reply/uptake on my resize event comment.
These came out of a scan I did of the console with Chrome's [Modern Web Guidance](https://developer.chrome.com/docs/modern-web-guidance) skill, which gives an agent a set of guides on current web platform features to check a codebase against. Each change is its own commit. - **Set `color-scheme` from the chosen theme.** Our `<meta name="color-scheme" content="dark light">` tag tells the browser to pick a scheme from the OS preference, and the theme toggle only set `data-theme` on `<html>`. So browser-drawn UI (native scrollbars, date pickers, autofill) followed the OS and not the chosen theme. With a light OS and the default dark theme, the side modal's scrollbar was drawn for a light page: a white track with classic scrollbars, or a dark thumb on the dark background with macOS overlay scrollbars. Now `data-theme` also sets the `color-scheme` CSS property. - **Add `autoComplete="current-password"` to the login form's password field.** Password managers use it to tell a login form from a signup form. The username field already had `autoComplete="username"`. - **Drive table scroll shadows with a CSS scroll timeline.** The shadows on the sticky first column and the actions column were toggled by a `useIsOverflow` hook that listened to scroll and resize events, throttled with `lodash.throttle`. They are now an animation tied to the table's horizontal scroll position with `animation-timeline: scroll(nearest inline)`, so the hook and `lodash.throttle` are gone. The shadow fades in over the first 2rem of scroll instead of snapping on. Scroll timelines need Chrome 115 (July 2023), Safari 26 (September 2025) or Firefox 159 (October 2026), which is only two weeks old. The rules are inside `@supports`, so older Firefox and Safari lose the shadows and nothing else. I think that is fine: the scrollbar is still always visible. The shadows were also very hard to see, especially in the dark theme, so I made them stronger. - **Use a theme color for the table scrollbar thumb.** The SimpleBar thumb was hard-coded white at 28% opacity, which is nearly invisible in the light theme. It is now `--content-quaternary`, and `--content-tertiary` on hover. - **Drop the `uuid` package.** This one is not from the scan. The mock API now uses `crypto.randomUUID()`, which needs a secure context (HTTPS or localhost), as MSW's service worker already does. Toast IDs were the only use in the app itself, and I replaced those with a simple counter because the console is occasionally served over plain HTTP, e.g., from Nexus on a remote dev machine. `uuid.validate` in the mock API is replaced by a regex that matches any UUID version, [as Nexus does](https://github.com/oxidecomputer/omicron/blob/aa28c9c/common/src/api/external/mod.rs#L357-L367). I also tried replacing SimpleBar with native `scrollbar-color` and `scrollbar-width`, which one of the guides recommends, and dropped it. SimpleBar was added in #1310 to keep the table's horizontal scrollbar visible so it's clear the table overflows. Firefox on macOS can't do that natively: overlay scrollbars hide until you scroll. I checked the shadows and the scrollbar thumb in Chromium in both themes, and that Firefox 151, which has no scroll timelines, shows no shadows. ### `color-scheme`: light OS, dark theme Before, the overlay scrollbar thumb on the right is dark on a dark background. <img width="2144" height="1298" alt="color-scheme" src="https://github.com/user-attachments/assets/a7ca8062-c0e1-4f59-aed9-06d1ed7b9589" /> ### Scroll shadows <img width="1488" height="1336" alt="shadows" src="https://github.com/user-attachments/assets/addb6073-ae4e-412b-bc46-a0577238d79f" /> ### Table scrollbar thumb in light theme <img width="1488" height="804" alt="thumb" src="https://github.com/user-attachments/assets/44fb4cd2-6db9-4a3a-9628-6bcd0efe4047" />




Draft proof of concept:

If this approach makes sense I can work it up into something a little neater. I'm doing most of this using css selectors, not sure if it's worth moving more of it into tailwind.
There's a hook that checks if the table overflows and applies the overflow indicator on both ends unless you are scrolled all the way in either direction.
It's also worth using elevation to better show that the first and last cell are sitting on top of the others.
Known issues: