fix: codesanbox bug (#2842)

This commit is contained in:
jack zhang 2023-10-16 15:03:32 +08:00 committed by GitHub
parent dd892f5bae
commit dc97149164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 18 deletions

View File

@ -202,15 +202,13 @@ const PreviewerActions: typeof DumiPreviewerActions = (props) => {
useEffect(() => { useEffect(() => {
if (div.current) { if (div.current) {
const elements = div.current.querySelectorAll('.dumi-default-previewer-actions'); const element = div.current.querySelector('.dumi-default-previewer-action-btn');
elements.forEach((element) => { element?.addEventListener('click', (e) => {
element.addEventListener('click', (e) => { e.stopImmediatePropagation();
e.stopImmediatePropagation(); setLoading(true);
setLoading(true); openCodeSandbox(props).finally(() => {
openCodeSandbox(props).finally(() => { setLoading(false);
setLoading(false); });
});
})
}) })
} }
}, [div]) }, [div])

View File

@ -202,15 +202,13 @@ const PreviewerActions: typeof DumiPreviewerActions = (props) => {
useEffect(() => { useEffect(() => {
if (div.current) { if (div.current) {
const elements = div.current.querySelectorAll('.dumi-default-previewer-actions'); const element = div.current.querySelector('.dumi-default-previewer-action-btn');
elements.forEach((element) => { element?.addEventListener('click', (e) => {
element.addEventListener('click', (e) => { e.stopImmediatePropagation();
e.stopImmediatePropagation(); setLoading(true);
setLoading(true); openCodeSandbox(props).finally(() => {
openCodeSandbox(props).finally(() => { setLoading(false);
setLoading(false); });
});
})
}) })
} }
}, [div]) }, [div])