Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slow-seas-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

FilteredActionList: Adds new prop `scrollBehavior` to allow customization of scroll behavior
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@github/tab-container-element": "^4.8.2",
"@lit-labs/react": "1.2.1",
"@oddbird/popover-polyfill": "^0.5.2",
"@primer/behaviors": "^1.9.1",
"@primer/behaviors": "^1.10.0",
"@primer/live-region-element": "^0.7.1",
"@primer/octicons-react": "^19.21.0",
"@primer/primitives": "10.x || 11.x",
Expand Down
18 changes: 14 additions & 4 deletions packages/react/src/FilteredActionList/FilteredActionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ export interface FilteredActionListProps extends Partial<Omit<GroupedListProps,
* Default is false.
*/
focusPrependedElements?: boolean
/**
* Determines the scroll behavior of the container when an item is focused.
*
* @default 'auto'
*/
scrollBehavior?: ScrollBehavior
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scrollBehavior prop lacks an explicit type import. While ScrollBehavior appears to be a built-in DOM type, it would be clearer to either import it from @primer/behaviors (if it's exported there) or use a union type like 'auto' | 'instant' | 'smooth' to match the documented options in the JSDoc comment.

Suggested change
scrollBehavior?: ScrollBehavior
scrollBehavior?: 'auto' | 'instant' | 'smooth'

Copilot uses AI. Check for mistakes.
}

export function FilteredActionList({
Expand Down Expand Up @@ -136,6 +142,7 @@ export function FilteredActionList({
disableSelectOnHover = false,
setInitialFocus = false,
focusPrependedElements,
scrollBehavior,
...listProps
}: FilteredActionListProps): JSX.Element {
const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate(externalFilterValue, undefined, '')
Expand Down Expand Up @@ -258,8 +265,11 @@ export function FilteredActionList({
activeDescendantFocus: inputRef,
onActiveDescendantChanged: (current, previous, directlyActivated) => {
activeDescendantRef.current = current
if (current && scrollContainerRef.current && directlyActivated) {
scrollIntoView(current, scrollContainerRef.current, menuScrollMargins)
if (current && scrollContainerRef.current && (directlyActivated || focusPrependedElements)) {
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition for triggering scroll has been changed from directlyActivated to (directlyActivated || focusPrependedElements). This behavioral change is not documented in the PR description or changeset, and it's unclear if this is intentional or a side effect. If this is an intentional fix, it should be documented separately. If it's related to the scrollBehavior feature, the relationship should be explained.

Suggested change
if (current && scrollContainerRef.current && (directlyActivated || focusPrependedElements)) {
if (current && scrollContainerRef.current && directlyActivated) {

Copilot uses AI. Check for mistakes.
scrollIntoView(current, scrollContainerRef.current, {
...menuScrollMargins,
behavior: scrollBehavior,
})
}

onActiveDescendantChanged?.(current, previous, directlyActivated)
Expand All @@ -276,10 +286,10 @@ export function FilteredActionList({
if (activeDescendantRef.current && scrollContainerRef.current) {
scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, {
...menuScrollMargins,
behavior: 'auto',
behavior: scrollBehavior,
})
}
}, [items, inputRef, scrollContainerRef])
}, [items, inputRef, scrollContainerRef, scrollBehavior])

useEffect(() => {
if (usingRovingTabindex) {
Expand Down
Loading