Skip to content

Commit

Permalink
fix(Popup): opened event is emitted twice when duration is 0 (#11902)
Browse files Browse the repository at this point in the history
* fix(Popup): duration 0s and enable lazyRender opened is executed twice

* fix(Popup): optimized code
  • Loading branch information
zhousg authored May 28, 2023
1 parent d972688 commit 6177bf0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vant/src/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ export default defineComponent({
}
};

const onOpened = () => emit('opened');
// see: https://github.com/youzan/vant/issues/11901
let timer: ReturnType<typeof setTimeout> | null;
const onOpened = () => {
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
emit('opened');
});
};
const onClosed = () => emit('closed');
const onKeydown = (event: KeyboardEvent) => emit('keydown', event);

Expand Down

0 comments on commit 6177bf0

Please sign in to comment.