Skip to content

Commit 3881930

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 9106862 commit 3881930

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
## Changed
12+
13+
- 🚨(frontend) block button when creating doc #749
14+
1115
## Fixed
1216

1317
- 🐛(back) validate document content in serializer #822

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
3333
useCmdK(openSearchModal);
3434
const { togglePanel } = useLeftPanelStore();
3535

36-
const { mutate: createDoc } = useCreateDoc({
36+
const { mutate: createDoc, isPending: isCreatingDoc } = useCreateDoc({
3737
onSuccess: (doc) => {
3838
router.push(`/docs/${doc.id}`);
3939
togglePanel();
@@ -81,7 +81,9 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
8181
)}
8282
</Box>
8383
{authenticated && (
84-
<Button onClick={createNewDoc}>{t('New doc')}</Button>
84+
<Button onClick={createNewDoc} disabled={isCreatingDoc}>
85+
{t('New doc')}
86+
</Button>
8587
)}
8688
</Box>
8789
</SeparatedSection>

0 commit comments

Comments
 (0)