fix(app): hide the side tab scrollbar, fade both edges, and even out the + gap (#58580)

This commit is contained in:
Kit Langton
2026-10-23 20:04:47 -07:00
committed by GitHub
Unverified
parent 011a3435d4
commit d42a95977b
2 changed files with 73 additions and 5 deletions
@@ -17,12 +17,39 @@ export const nextTabStripScrollLeft = (input: Input) => {
return input.scrollWidth - input.clientWidth
}
const EDGE_FADE = 24
export const createTabStripScroll = (input: { el: HTMLDivElement; lead: () => boolean }) => {
let frame: number | undefined
let prevScrollWidth = input.el.scrollWidth
let prevLeadOpen = input.lead()
const written: Record<string, string> = {}
// Each edge fades by as much as the strip has scrolled past it, up to EDGE_FADE, so the masks grow in with the
// scroll instead of popping. The end fade stops at the sticky "+", the strip's last child, which stays unmasked.
// RTL strips scroll to negative offsets.
const fade = () => {
const offset = Math.abs(input.el.scrollLeft)
const add = input.el.lastElementChild instanceof HTMLElement ? input.el.lastElementChild.offsetWidth : 0
const rest = input.el.scrollWidth - input.el.clientWidth - offset
write("--tab-strip-fade-start", Math.min(offset, EDGE_FADE))
write("--tab-strip-fade-end", Math.min(Math.max(rest, 0), EDGE_FADE))
write("--tab-strip-add", add)
}
// Only changed values are written, so scrolling well inside the strip restyles nothing.
const write = (name: string, px: number) => {
const value = `${Math.round(px)}px`
if (written[name] === value) return
written[name] = value
input.el.style.setProperty(name, value)
}
const update = () => {
fade()
const scrollWidth = input.el.scrollWidth
const clientWidth = input.el.clientWidth
const leadOpen = input.lead()
@@ -61,12 +88,30 @@ export const createTabStripScroll = (input: { el: HTMLDivElement; lead: () => bo
}
input.el.addEventListener("wheel", onWheel, { passive: false })
const observer = new MutationObserver(schedule)
input.el.addEventListener("scroll", fade, { passive: true })
// The strip and each tab, so a resized strip or a retitled tab updates the fades; opening and closing tabs updates
// them through `update`.
const resize = new ResizeObserver(fade)
resize.observe(input.el)
Array.from(input.el.children).forEach((child) => resize.observe(child))
const observer = new MutationObserver((records) => {
records.forEach((record) => {
record.addedNodes.forEach((node) => node instanceof Element && resize.observe(node))
record.removedNodes.forEach((node) => node instanceof Element && resize.unobserve(node))
})
schedule()
})
observer.observe(input.el, { childList: true })
return () => {
input.el.removeEventListener("wheel", onWheel)
input.el.removeEventListener("scroll", fade)
observer.disconnect()
resize.disconnect()
if (frame !== undefined) cancelAnimationFrame(frame)
}
+27 -4
View File
@@ -589,18 +589,41 @@
height: var(--tabs-bar-height);
padding-inline-end: 0;
border-bottom: none;
/* Tabs fade out at each edge with more of them past it. The tab strip's scroll handler sets the fade widths and the
width of the sticky "+", which the second layer keeps unmasked. */
mask-image:
linear-gradient(
to right,
transparent,
#000 var(--tab-strip-fade-start, 0px),
#000 calc(100% - var(--tab-strip-add, 0px) - var(--tab-strip-fade-end, 0px)),
transparent calc(100% - var(--tab-strip-add, 0px))
),
linear-gradient(to left, #000 var(--tab-strip-add, 0px), transparent var(--tab-strip-add, 0px));
&:dir(rtl) {
mask-image:
linear-gradient(
to left,
transparent,
#000 var(--tab-strip-fade-start, 0px),
#000 calc(100% - var(--tab-strip-add, 0px) - var(--tab-strip-fade-end, 0px)),
transparent calc(100% - var(--tab-strip-add, 0px))
),
linear-gradient(to right, #000 var(--tab-strip-add, 0px), transparent var(--tab-strip-add, 0px));
}
}
/* The end gap lives inside the sticky "+" box. Sticky offsets respect the strip's padding, so padding there
would leave a gap after the "+" where scrolled tabs show through. */
/* The "+" sits flush with the strip's end, so it keeps the tabs' 8px gap both from the last tab and from the
controls after the strip. The strip's mask fades the tabs under it. */
:root
body
:is(#review-panel, #bottom-panel)
[data-component="tabs"]
.session-review-v2-tabs-bar
[data-slot="tabs-list"]
> .sticky {
padding-inline-end: 12px;
> .sticky::before {
display: none;
}
:root