Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dialog): beforeOpen double trigger #4838

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/dialog/_usage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<template #dialog="{ configProps }"
><div>
<t-button @click="visible = true">Open Modal</t-button>
<t-dialog v-bind="configProps" v-model:visible="visible">
<t-dialog
v-bind="configProps"
v-model:visible="visible"
@opened="opened"
@closed="closed"
@before-open="BeforeOpen"
@before-close="BeforeClose"
>
<p>This is a dialog</p>
</t-dialog>
</div></template
Expand All @@ -24,9 +31,25 @@ const handleClick = () => {
const configList = ref(configJson);
const panelList = [{ label: 'dialog', value: 'dialog' }];

const BeforeOpen = () => {
console.log('before open');
};

const BeforeClose = () => {
console.log('before close');
};

const opened = () => {
console.log('opened');
};

const closed = () => {
console.log('closed');
};

const usageCodeMap = {
dialog:
'\n <div>\n <t-button @click="visible = true">Open Modal</t-button>\n <t-dialog v-bind="configProps" v-model:visible="visible">\n <p>This is a dialog</p>\n </t-dialog>\n </div>\n ',
'\n <div>\n <t-button @click="visible = true">Open Modal</t-button>\n <t-dialog v-bind="configProps" v-model:visible="visible" @opened="opened" @closed="closed" @before-open="BeforeOpen" @before-close="BeforeClose">\n <p>This is a dialog</p>\n </t-dialog>\n </div>\n ',
};
const usageCode = ref(`<template>${usageCodeMap[panelList[0].value].trim()}</template>`);

Expand Down
1 change: 1 addition & 0 deletions src/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import type { TdDialogProps } from './type';
import useTeleport from '../hooks/useTeleport';
import usePopupManager from '../hooks/usePopupManager';
import debounce from 'lodash/debounce';

Check warning on line 21 in src/dialog/dialog.tsx

View workflow job for this annotation

GitHub Actions / call-test-build / test

'debounce' is defined but never used. Allowed unused vars must match /^_/u

function GetCSSValue(v: string | number) {
return Number.isNaN(Number(v)) ? v : `${Number(v)}px`;
Expand Down
Loading