Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ff4ba0

Browse files
authored
fix: scroll item list into view when openingMultiSelectCombobox (#19806)
1 parentc9a877a commit8ff4ba0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎site/src/components/MultiSelectCombobox/MultiSelectCombobox.tsx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export const MultiSelectCombobox = forwardRef<
216216
const[onScrollbar,setOnScrollbar]=useState(false);
217217
const[isLoading,setIsLoading]=useState(false);
218218
constdropdownRef=useRef<HTMLDivElement>(null);
219+
constlistRef=useRef<HTMLDivElement>(null);
219220

220221
const[selected,setSelected]=useState<Option[]>(
221222
arrayDefaultOptions??[],
@@ -364,6 +365,15 @@ export const MultiSelectCombobox = forwardRef<
364365
voidexec();
365366
},[debouncedSearchTerm,groupBy,open,triggerSearchOnFocus,onSearch]);
366367

368+
// Scroll dropdown into view on open
369+
useEffect(()=>{
370+
if(!open||!listRef.current){
371+
return;
372+
}
373+
374+
listRef.current.scrollIntoView({behavior:"smooth"});
375+
},[open]);
376+
367377
constCreatableItem=()=>{
368378
if(!creatable){
369379
returnundefined;
@@ -603,7 +613,7 @@ export const MultiSelectCombobox = forwardRef<
603613
</div>
604614
</div>
605615
</div>
606-
<divclassName="relative">
616+
<divclassName="relative"ref={listRef}>
607617
{open&&(
608618
<CommandList
609619
className={`absolute top-1 z-10 w-full rounded-md

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp