mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Tag): incorrect transition when set closeable dynamically
This commit is contained in:
parent
6c5cb8827b
commit
fe6e2f29ba
@ -83,6 +83,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__close {
|
&__close {
|
||||||
|
min-width: 1em;
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,31 +44,30 @@ function Tag(
|
|||||||
classes[size] = size;
|
classes[size] = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Content = (
|
const CloseIcon = props.closeable && (
|
||||||
<span
|
<Icon
|
||||||
style={style}
|
name="cross"
|
||||||
class={[bem([classes, type]), { [BORDER_SURROUND]: plain }]}
|
class={bem('close')}
|
||||||
{...inherit(ctx, true)}
|
onClick={(event: PointerEvent) => {
|
||||||
>
|
event.stopPropagation();
|
||||||
{slots.default?.()}
|
emit(ctx, 'close');
|
||||||
{props.closeable && (
|
}}
|
||||||
<Icon
|
/>
|
||||||
name="cross"
|
|
||||||
class={bem('close')}
|
|
||||||
onClick={(event: PointerEvent) => {
|
|
||||||
event.stopPropagation();
|
|
||||||
emit(ctx, 'close');
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (props.closeable) {
|
return (
|
||||||
return <transition name="van-fade">{Content}</transition>;
|
<transition name={props.closeable ? 'van-fade' : ''}>
|
||||||
}
|
<span
|
||||||
|
key="content"
|
||||||
return Content;
|
style={style}
|
||||||
|
class={[bem([classes, type]), { [BORDER_SURROUND]: plain }]}
|
||||||
|
{...inherit(ctx, true)}
|
||||||
|
>
|
||||||
|
{slots.default?.()}
|
||||||
|
{CloseIcon}
|
||||||
|
</span>
|
||||||
|
</transition>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag.props = {
|
Tag.props = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user