Skip to content

Commit

Permalink
Avoid scrollToIndex when using native scrollbar in ComboBox
Browse files Browse the repository at this point in the history
  • Loading branch information
danthomps committed May 9, 2024
1 parent 031b39d commit 86c8a82
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,14 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
actions.setActivationTrigger(ActivationTrigger.Pointer)
})

// When the user scrolls **using the native scrollbar**, the only event fired is
// the onScroll event. We need to make sure to set the current activation
// trigger to pointer, in order to let them scroll through the list.
let handleScroll = useEvent(() => {
if (isMobile()) return
actions.setActivationTrigger(ActivationTrigger.Pointer)
})

let ourProps = mergeProps(anchor ? getFloatingPanelProps() : {}, {
'aria-labelledby': labelledBy,
role: 'listbox',
Expand All @@ -1675,6 +1683,7 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
'--button-width': useElementSize(data.buttonRef, true).width,
} as CSSProperties,
onWheel: handleWheel,
onScroll: handleScroll,
})

// Map the children in a scrollable container when virtualization is enabled
Expand Down

0 comments on commit 86c8a82

Please sign in to comment.