Skip to content

Commit

Permalink
fix: [tooltip]修复autoPlacementList报错问题 fix #1029
Browse files Browse the repository at this point in the history
  • Loading branch information
hxh2010 authored and albyben committed Jan 3, 2025
1 parent 348ffbc commit 0c44bb2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/popper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
useImperativeHandle,
MutableRefObject,
} from 'react'
import { createPopper, Instance, Modifier, OptionsGeneric, Placement } from '@popperjs/core'
import { createPopper, Instance, Modifier, OptionsGeneric, Placement, VirtualElement } from '@popperjs/core'
import { tuple } from '../_utils/type'
import classnames from 'classnames'
import debounce from 'lodash/debounce'
Expand Down Expand Up @@ -61,8 +61,9 @@ export type PopperProps = {
mouseLeaveDelay?: number
defaultVisible?: boolean
autoPlacement?: boolean
autoPlacementList?: PlacementType[]
backgroundTransparent?: boolean
autoPlacementList?: Placement[]

className?: string
style?: React.CSSProperties
popperClassName?: string
Expand Down Expand Up @@ -128,7 +129,7 @@ const getRealPlacement = (key: PlacementType) => {
return popperPlacementMap[key] ? (popperPlacementMap[key] as Placement) : 'top'
}

const getFallbackPlacementList: (arr: string[]) => Placement[] = (arr) => {
const getFallbackPlacementList: (arr: PlacementType[]) => Placement[] = (arr) => {
return arr
.map((d) => {
return popperPlacementMap[d as PlacementType] ? popperPlacementMap[d as PlacementType] : ''
Expand Down Expand Up @@ -607,7 +608,9 @@ export const Popper = forwardRef<SubPopup | null, PopperProps>((props, ref) => {

if (current) {
popperInstance.current = createPopper(
trigger === 'contextMenu' ? virtualElement : current?.closest(`.${referencePrefixCls}`) || current,
trigger === 'contextMenu'
? (virtualElement as VirtualElement)
: current?.closest(`.${referencePrefixCls}`) || current,
popperRefDom.current as HTMLElement,
popperOptionsInner,
)
Expand Down

0 comments on commit 0c44bb2

Please sign in to comment.