fix(app): feather the sidebar list's scroll edges (#59467)

This commit is contained in:
Kit Langton
2026-10-29 21:01:00 -07:00
committed by GitHub
Unverified
parent 1a5cd8bfb5
commit 0da727dc11
3 changed files with 57 additions and 6 deletions
+11
View File
@@ -579,8 +579,19 @@ test("vertical tabs resize, scroll, show shortcut hints, and navigate", async ({
await resize(-380, "260px")
const scroll = sidebar.locator('[data-slot="vertical-tabs-scroll"]')
// The list feathers only the edges with more rows past them.
const feather = () =>
scroll.evaluate((element) => {
const style = getComputedStyle(element)
return [style.getPropertyValue("--vertical-tabs-fade-top"), style.getPropertyValue("--vertical-tabs-fade-bottom")]
})
await expect.poll(feather).toEqual(["0px", "16px"])
await scroll.evaluate((element) => element.scrollTo(0, element.scrollHeight))
await expect(tabB).toBeInViewport({ ratio: 1 })
await expect.poll(feather).toEqual(["16px", "0px"])
await page.locator("html").evaluate((element) => element.setAttribute("dir", "rtl"))
const home = sidebar.locator('[data-action="vertical-tabs-home"]')
+30 -2
View File
@@ -1,4 +1,5 @@
import { createEffect, createMemo, createResource, For, onCleanup, Show } from "solid-js"
import { createEffect, createMemo, createResource, For, onCleanup, onMount, Show } from "solid-js"
import { createResizeObserver } from "@solid-primitives/resize-observer"
import { createStore } from "solid-js/store"
import { DragDropProvider, PointerSensor } from "@dnd-kit/solid"
import { isSortable, useSortable } from "@dnd-kit/solid/sortable"
@@ -392,6 +393,22 @@ export function TitlebarTabStrip(props: {
const command = useCommand()
const vertical = () => props.orientation === "vertical"
let listRef!: HTMLDivElement
let scrollRef!: HTMLDivElement
// Each vertical edge feathers by as much as there is left to scroll past it, so it appears and leaves without a jump.
const [fade, setFade] = createStore({ top: 0, bottom: 0 })
const measureFade = () =>
setFade({
top: Math.min(16, Math.round(scrollRef.scrollTop)),
bottom: Math.min(
16,
Math.max(0, Math.round(scrollRef.scrollHeight - scrollRef.clientHeight - scrollRef.scrollTop)),
),
})
onMount(() => {
if (vertical()) createResizeObserver([scrollRef, listRef], measureFade)
})
const [visibility, setVisibility] = createStore<Record<string, boolean>>({})
const [unread, setUnread] = createStore<Record<string, boolean>>({})
const visibleTabs = createMemo(() => props.tabs.filter((tab) => tab.type === "draft" || visibility[tabKey(tab)]))
@@ -482,12 +499,21 @@ export function TitlebarTabStrip(props: {
classList={{ "min-h-0 overflow-hidden": vertical() }}
>
<div
ref={scrollRef}
data-slot={vertical() ? "vertical-tabs-scroll" : "titlebar-tabs-scroll"}
class="flex min-w-0 no-scrollbar [app-region:no-drag]"
classList={{
"flex-row items-center gap-1.5 overflow-x-auto": !vertical(),
"max-h-full flex-col overflow-y-auto overflow-x-hidden": vertical(),
}}
style={
vertical()
? { "--vertical-tabs-fade-top": `${fade.top}px`, "--vertical-tabs-fade-bottom": `${fade.bottom}px` }
: undefined
}
onScroll={() => {
if (vertical()) measureFade()
}}
>
<DragDropProvider
sensors={[
@@ -498,7 +524,9 @@ export function TitlebarTabStrip(props: {
: [new PointerActivationConstraints.Distance({ value: 4 })],
preventActivation: (event) =>
event.target instanceof Element &&
!!event.target.closest('[data-slot="tab-close"], [contenteditable="true"], [contenteditable="plaintext-only"]'),
!!event.target.closest(
'[data-slot="tab-close"], [contenteditable="true"], [contenteditable="plaintext-only"]',
),
}),
]}
modifiers={[
+16 -4
View File
@@ -10,11 +10,23 @@
[data-slot="vertical-tabs-sidebar"] [data-slot="vertical-tabs-scroll"] {
min-height: 0;
/* Leave enough space to scroll the final tab clear of the fade above Settings. */
padding-block-end: 16px;
scroll-padding-block-end: 16px;
-webkit-mask-image: linear-gradient(to bottom, black calc(100% - 16px), transparent);
mask-image: linear-gradient(to bottom, black calc(100% - 16px), transparent);
/* Keyboard navigation scrolls a tab clear of the feathered edges, which TitlebarTabStrip sizes from the scroll. */
scroll-padding-block: 16px;
-webkit-mask-image: linear-gradient(
to bottom,
transparent,
black var(--vertical-tabs-fade-top, 0px),
black calc(100% - var(--vertical-tabs-fade-bottom, 0px)),
transparent
);
mask-image: linear-gradient(
to bottom,
transparent,
black var(--vertical-tabs-fade-top, 0px),
black calc(100% - var(--vertical-tabs-fade-bottom, 0px)),
transparent
);
}
[data-slot="mobile-tabs-trigger"][aria-expanded="true"] {