Skip to content

Commit

Permalink
fix(pro:search): segment input scroll event doesn't work in safari (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Sep 18, 2023
1 parent e211465 commit 1caabb8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/pro/search/src/components/segment/SegmentInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {

import { debounce } from 'lodash-es'

import { isSafari } from '@idux/cdk/platform'
import { useResizeObserver } from '@idux/cdk/resize'
import { getScroll, setScroll } from '@idux/cdk/scroll'
import { callEmit, convertCssPixel, useEventListener, useState } from '@idux/cdk/utils'
Expand Down Expand Up @@ -231,8 +232,8 @@ function useSegmentScroll(

onMounted(() => {
if (props.ellipsis) {
/* eslint-disable indent */
listenerStops = [
useEventListener(inputRef, 'scroll', updateScroll),
useResizeObserver(inputRef, () => {
if (document.activeElement === inputRef.value) {
scrollIntoView()
Expand All @@ -241,7 +242,15 @@ function useSegmentScroll(
}),
useEventListener(inputRef, 'input', updateScroll),
useEventListener(inputRef, 'compositionend', scrollIntoView),
]
...(isSafari
? [
useEventListener(inputRef, 'keydown', updateScroll),
useEventListener(inputRef, 'wheel', updateScroll),
useEventListener(inputRef, 'select', updateScroll),
]
: [useEventListener(inputRef, 'scroll', updateScroll)]),
].filter(Boolean)
/* eslint-enable indent */
}
})

Expand Down

0 comments on commit 1caabb8

Please sign in to comment.