Skip to content

Commit

Permalink
fix(drawer): unexpected event triggering
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs committed Jan 10, 2024
1 parent 3f25f5c commit 24ea75c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default defineComponent({
});

const handleEscKeydown = (e: KeyboardEvent) => {
if (props.closeOnEscKeydown ?? (globalConfig.value.closeOnEscKeydown && e.key === 'Escape')) {
if (props.closeOnEscKeydown ?? (globalConfig.value.closeOnEscKeydown && e.key === 'Escape' && isVisible.value)) {
props.onEscKeydown?.({ e });
closeDrawer({ trigger: 'esc', e });
}
Expand Down Expand Up @@ -214,10 +214,7 @@ export default defineComponent({
};
const onKeyDown = (e: KeyboardEvent) => {
// 根据closeOnEscKeydown判断按下ESC时是否触发close事件
if ((props.closeOnEscKeydown ?? globalConfig.value.closeOnEscKeydown) && e.key === 'Escape') {
props.onEscKeydown?.({ e });
closeDrawer({ trigger: 'esc', e });
}
handleEscKeydown(e);
};
const closeDrawer = (params: DrawerCloseContext) => {
props.onClose?.(params);
Expand Down

0 comments on commit 24ea75c

Please sign in to comment.