Skip to content

Commit 87a6d3a

Browse files
committed
🚨(frontend) block button when creating doc
When the user clicks on the button to create a new doc, the button is disabled to prevent multiple clicks. Multiple clicks on the button could create multiple docs and create a error about duplicated paths.
1 parent 8938eca commit 87a6d3a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to
1818

1919
- 🧑‍💻(frontend) change literal section open source #702
2020
- ♻️(frontend) replace cors proxy for export #695
21+
- 🚨(frontend) block button when creating doc #749
2122

2223
## Fixed
2324

src/frontend/apps/impress/src/features/left-panel/components/LeftPanelHeader.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
2727
useCmdK(openSearchModal);
2828
const { togglePanel } = useLeftPanelStore();
2929

30-
const { mutate: createDoc } = useCreateDoc({
30+
const { mutate: createDoc, isPending: isCreatingDoc } = useCreateDoc({
3131
onSuccess: (doc) => {
3232
router.push(`/docs/${doc.id}`);
3333
togglePanel();
@@ -75,7 +75,9 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
7575
)}
7676
</Box>
7777
{authenticated && (
78-
<Button onClick={createNewDoc}>{t('New doc')}</Button>
78+
<Button onClick={createNewDoc} disabled={isCreatingDoc}>
79+
{t('New doc')}
80+
</Button>
7981
)}
8082
</Box>
8183
</SeparatedSection>

0 commit comments

Comments
 (0)