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 { &__close {
min-width: 1em;
margin-left: 2px; margin-left: 2px;
} }
} }

View File

@ -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 = {