Skip to content

Commit c0197a6

Browse files
committed
fix(global-search): adjust group header height to align
1 parent faa35bd commit c0197a6

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

plugins/global-search/src/components/GroupHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const GroupHeader = memo(
3737
"group w-full focus:outline-none cursor-pointer text-left data-[header=normal]:absolute data-[header=normal]:left-0 data-[header=sticky]:sticky data-[header=sticky]:-top-px data-[header=sticky]:z-10 z-20",
3838
index === 0 && "data-[header=sticky]:top-0",
3939
showFadeOut &&
40-
"after:content-[] after:absolute after:top-10 after:left-0 after:right-0 after:h-3 after:z-10 after:pointer-events-none after:bg-gradient-to-b after:from-modal-light dark:after:from-modal-dark after:to-transparent",
40+
"after:content-[] after:absolute after:top-(--header-height) after:left-0 after:right-0 after:h-3 after:z-10 after:pointer-events-none after:bg-gradient-to-b after:from-modal-light dark:after:from-modal-dark after:to-transparent",
4141
className
4242
)}
4343
data-header={isSticky ? "sticky" : "normal"}
@@ -46,12 +46,12 @@ export const GroupHeader = memo(
4646
{...props}
4747
{...getFocusProps(headerId(entry.id))}
4848
>
49-
<div className="h-9 mt-1 bg-modal-light dark:bg-modal-dark">
49+
<div className="h-[calc(100%-5px)] mt-1 bg-modal-light dark:bg-modal-dark">
5050
<hr
5151
className="border-divider-light dark:border-divider-dark aria-hidden:border-modal-light dark:aria-hidden:border-modal-dark mb-1"
5252
aria-hidden={index === 0}
5353
/>
54-
<div className="h-8 flex flex-row gap-2 rounded-lg justify-start items-center select-none overflow-hidden ps-2 group-focus-visible:bg-option-light dark:group-focus-visible:bg-option-dark group-focus-visible:text-primary-light dark:group-focus-visible:text-primary-dark">
54+
<div className="h-[calc(100%-10px)] flex flex-row gap-2 rounded-lg justify-start items-center select-none overflow-hidden ps-2 group-focus-visible:bg-option-light dark:group-focus-visible:bg-option-dark group-focus-visible:text-primary-light dark:group-focus-visible:text-primary-dark">
5555
<div className="flex-shrink-0 flex gap-2 justify-start items-center">
5656
<IconArrowRight
5757
className={cn(

plugins/global-search/src/components/Results.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,21 @@ export function ResultsList({ groups }: ResultsProps) {
1818
const { virtualItems, virtualItemIds, stickyIndexes } = useProcessedResults(groups, collapsedGroups)
1919
const { setItems } = useSelection()
2020

21+
const computedStyles = scrollElementRef.current ? getComputedStyle(scrollElementRef.current) : null
22+
const headerValue = computedStyles?.getPropertyValue("--header-height")
23+
const itemValue = computedStyles?.getPropertyValue("--item-height")
24+
const headerHeight = typeof headerValue === "string" ? Number.parseInt(headerValue, 10) : null
25+
const itemHeight = typeof itemValue === "string" ? Number.parseInt(itemValue, 10) : null
26+
2127
const rowVirtualizer = useVirtualizer({
2228
overscan: 10,
2329
count: virtualItems.length,
2430
getScrollElement: () => scrollElementRef.current,
2531
estimateSize: index => {
2632
const item = virtualItems[index]
2733
if (!item) return 0
28-
if (item.type === "group-header") return 50
29-
return 30
34+
if (item.type === "group-header") return headerHeight ?? 48
35+
return itemHeight ?? 30
3036
},
3137
rangeExtractor: range => {
3238
// TODO: This sticky index could be added and put into the result more efficiently

plugins/global-search/src/styles.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
/* Spacing */
3434
--spacing: 5px;
35+
--header-height: 48px;
36+
--item-height: 30px;
3537
}
3638

3739
@utility scrollbar-hidden {

0 commit comments

Comments
 (0)