fix(Tag): incorrect transition when set closeable dynamically

This commit is contained in:
陈嘉涵 2019-12-28 09:00:22 +08:00 committed by neverland
parent 6c5cb8827b
commit fe6e2f29ba
2 changed files with 23 additions and 23 deletions

View File

@ -83,6 +83,7 @@
}
&__close {
min-width: 1em;
margin-left: 2px;
}
}

View File

@ -44,31 +44,30 @@ function Tag(
classes[size] = size;
}
const Content = (
<span
style={style}
class={[bem([classes, type]), { [BORDER_SURROUND]: plain }]}
{...inherit(ctx, true)}
>
{slots.default?.()}
{props.closeable && (
<Icon
name="cross"
class={bem('close')}
onClick={(event: PointerEvent) => {
event.stopPropagation();
emit(ctx, 'close');
}}
/>
)}
</span>
const CloseIcon = props.closeable && (
<Icon
name="cross"
class={bem('close')}
onClick={(event: PointerEvent) => {
event.stopPropagation();
emit(ctx, 'close');
}}
/>
);
if (props.closeable) {
return <transition name="van-fade">{Content}</transition>;
}
return Content;
return (
<transition name={props.closeable ? 'van-fade' : ''}>
<span
key="content"
style={style}
class={[bem([classes, type]), { [BORDER_SURROUND]: plain }]}
{...inherit(ctx, true)}
>
{slots.default?.()}
{CloseIcon}
</span>
</transition>
);
}
Tag.props = {