GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): keyboard highlight in the composer menu stays clear of the … · pingdotgg/t3code@36ff64e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/chat
    • ComposerCommandMenu.browser.test.tsx
    • ComposerCommandMenu.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/chat/ComposerCommandMenu.browser.test.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/ComposerCommandMenu.browser.test.tsx
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ it("brings a highlighted row far down a long list into the visible window", asyn
8686
await expect.element(option).toHaveAttribute("aria-setsize", "300");
8787
const surface = screen.container.querySelector<HTMLElement>("[data-composer-command-drawer]");
8888
expect(surface?.scrollTop, "outer menu surface scroll offset").toBe(0);
89+
const scroller = option.element().closest<HTMLElement>(".overscroll-y-contain")!;
90+
// The bottom 24px sit under the scroll fade.
91+
await vi.waitFor(() =>
92+
expect(option.element().getBoundingClientRect().bottom, "row bottom").toBeLessThanOrEqual(
93+
scroller.getBoundingClientRect().bottom - 24,
94+
),
95+
);
8996
});
9097

9198
async function scrollListToEnd() {
Collapse file

‎apps/web/src/components/chat/ComposerCommandMenu.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/ComposerCommandMenu.tsx
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
140140
useLayoutEffect(() => {
141141
if (activeIndex < 0) return;
142142
// Element.scrollIntoView would also scroll the clipped menu surface and the page around it.
143-
void listRef.current?.scrollIndexIntoView({ index: activeIndex, animated: false });
143+
void listRef.current?.scrollIndexIntoView({
144+
index: activeIndex,
145+
animated: false,
146+
// Keeps the row clear of the scroll fades.
147+
viewportMargin: { start: 24, end: 24 },
148+
});
144149
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- a filter can keep the index while the list stays scrolled.
145150
}, [activeIndex, props.items]);
146151

@@ -194,13 +199,18 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
194199
onScroll={updateScrollFade}
195200
onReady={() => setListReady(true)}
196201
// LegendList sizes its first window from this element before its rows give it height, so
197-
// reserve the rows' minimum height (1.75rem each, plus p-2) until it has placed them.
202+
// reserve the rows' minimum height (1.75rem each, plus padding) until it has placed them.
198203
// Afterwards the list sizes to its rows, and a short window can shrink it.
199-
style={
200-
listReady ? {} : { minHeight: `min(${props.items.length * 1.75 + 1}rem, 18rem)` }
201-
}
204+
// Legend counts style padding (not class padding) in its scroll math.
205+
style={{
206+
paddingTop: 8,
207+
paddingBottom: 8,
208+
...(listReady
209+
? {}
210+
: { minHeight: `min(${props.items.length * 1.75 + 1}rem, 18rem)` }),
211+
}}
202212
className={cn(
203-
"max-h-72 min-h-0 scroll-py-6 overflow-x-hidden overscroll-y-contain p-2 [&::-webkit-scrollbar-track]:my-4",
213+
"max-h-72 min-h-0 scroll-py-6 overflow-x-hidden overscroll-y-contain px-2 [&::-webkit-scrollbar-track]:my-4",
204214
getVirtualizedScrollFadeClassName(scrollFade),
205215
)}
206216
/>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.