fix(auto-tip): [auto-tip] Fix the issue where the placement configuration always has old values (#1774)

This commit is contained in:
MomoPoppy 2024-07-26 17:18:03 +08:00 committed by GitHub
parent 78d02c90fb
commit 61c3abf44a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View File

@ -48,12 +48,13 @@ export const api = [
'focusHandler'
]
const initState = ({ reactive, showPopper, popperElm, referenceElm, props, inject, popperJS }) =>
const initState = ({ reactive, showPopper, popperElm, referenceElm, props, inject, popperJS, currentPlacement }) =>
reactive({
popperJS,
showPopper,
popperElm,
referenceElm,
currentPlacement,
timeout: null,
focusing: false,
expectedState: undefined,
@ -85,8 +86,19 @@ export const renderless = (
Object.assign(popperParam, { slots, onBeforeUnmount, onDeactivated, watch })
const { showPopper, updatePopper, popperElm, referenceElm, doDestroy, popperJS } = userPopper(popperParam as any)
const state: ITooltipState = initState({ reactive, showPopper, popperElm, referenceElm, props, inject, popperJS })
const { showPopper, updatePopper, popperElm, referenceElm, doDestroy, popperJS, currentPlacement } = userPopper(
popperParam as any
)
const state: ITooltipState = initState({
reactive,
showPopper,
popperElm,
referenceElm,
props,
inject,
popperJS,
currentPlacement
})
Object.assign(api, {
state,

View File

@ -67,6 +67,7 @@ const mouseenterHandler = (e) => {
tooltipContent.value = currentTarget.boundingValue?.content || currentTarget.textContent
tooltip.state.referenceElm = currentTarget
tooltip.state.currentPlacement = getPlacement(currentTarget)
if (popperElm) {
popperElm.classList.replace(