Skip to content

Commit

Permalink
fix(comp:*): overlay animating cls should be set only at leaving (#1552)
Browse files Browse the repository at this point in the history
* fix(comp:*): overlay animating cls should be set only at leaving

* fix: temp
  • Loading branch information
sallerli1 committed May 17, 2023
1 parent 04e2500 commit c0d2e9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions packages/components/_private/overlay/src/Overlay.tsx
Expand Up @@ -27,7 +27,7 @@ import { isFunction } from 'lodash-es'
import { vClickOutside } from '@idux/cdk/click-outside'
import { type PopperElement, type PopperEvents, type PopperOptions, usePopper } from '@idux/cdk/popper'
import { CdkPortal } from '@idux/cdk/portal'
import { Logger, callEmit, convertElement, getFirstValidNode, useState } from '@idux/cdk/utils'
import { Logger, callEmit, convertElement, getFirstValidNode } from '@idux/cdk/utils'
import { useGlobalConfig } from '@idux/components/config'
import { useZIndex } from '@idux/components/utils'

Expand Down Expand Up @@ -90,12 +90,7 @@ export default defineComponent({
{ immediate: true },
)

const [isAnimating, setIsAnimating] = useState(false)
const onBeforeEnter = () => {
setIsAnimating(true)
}
const onAfterLeave = () => {
setIsAnimating(false)
if (props.destroyOnHide) {
destroy()
}
Expand Down Expand Up @@ -139,7 +134,6 @@ export default defineComponent({
props,
mergedPrefixCls,
visibility,
isAnimating,
currentZIndex,
contentNode!,
contentArrowRef,
Expand All @@ -152,7 +146,7 @@ export default defineComponent({
<>
{trigger}
<CdkPortal target={mergedContainer.value} load={visibility.value}>
<Transition appear name={props.transitionName} onBeforeEnter={onBeforeEnter} onAfterLeave={onAfterLeave}>
<Transition appear name={props.transitionName} onAfterLeave={onAfterLeave}>
{content}
</Transition>
</CdkPortal>
Expand Down Expand Up @@ -182,7 +176,6 @@ function renderContent(
props: OverlayProps,
mergedPrefixCls: ComputedRef<string>,
visibility: ComputedRef<boolean>,
isAnimating: ComputedRef<boolean>,
currentZIndex: ComputedRef<number>,
contentNode: VNode[],
arrowRef: Ref<PopperElement | undefined>,
Expand All @@ -195,16 +188,12 @@ function renderContent(
}

const prefixCls = mergedPrefixCls.value
const classes = {
[prefixCls]: true,
[`${prefixCls}-animating`]: isAnimating.value,
}

const { triggerId } = props
const overlayId = triggerId != null ? `__IDUX_OVERLAY-${triggerId}` : undefined
const style = `z-index: ${currentZIndex.value}`
const overlay = (
<div ref={popperRef} id={overlayId} class={classes} style={style} {...popperEvents.value} {...attrs}>
<div ref={popperRef} id={overlayId} class={prefixCls} style={style} {...popperEvents.value} {...attrs}>
{contentNode}
{props.showArrow && <div ref={arrowRef} class={`${prefixCls}-arrow`}></div>}
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/_private/overlay/style/index.less
Expand Up @@ -66,7 +66,7 @@
}
}

&[data-popper-reference-hidden]:not(&-animating) {
&[data-popper-reference-hidden] {
visibility: hidden;
opacity: 0;
pointer-events: none;
Expand Down

0 comments on commit c0d2e9c

Please sign in to comment.