-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent router prompt when using a block with subroutes in a form (#3281
- Loading branch information
1 parent
e65a401
commit bd562d3
Showing
8 changed files
with
60 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@comet/admin": minor | ||
--- | ||
|
||
Add `disableForcePromptRoute` option to `StackSwitch` | ||
|
||
This can be useful when a navigation in a switch shouldn't trigger a prompt, e.g., when navigating inside a block. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@comet/blocks-admin": patch | ||
--- | ||
|
||
Prevent router prompt when using a block with subroutes in a form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Field, FinalForm, SaveBoundary } from "@comet/admin"; | ||
import { AdminComponentRoot, createFinalFormBlock, createListBlock } from "@comet/blocks-admin"; | ||
import { ExternalLinkBlock } from "@comet/cms-admin"; | ||
|
||
import { dndProviderDecorator } from "../dnd.decorator"; | ||
import { snackbarDecorator } from "../docs/components/Snackbar/snackbar.decorator"; | ||
import { storyRouterDecorator } from "../story-router.decorator"; | ||
|
||
export default { | ||
decorators: [snackbarDecorator(), storyRouterDecorator(), dndProviderDecorator()], | ||
}; | ||
|
||
export const BlockInFinalFormWithSaveBoundary = () => { | ||
const LinkListBlock = createListBlock({ name: "LinkList", block: ExternalLinkBlock }); | ||
const FinalFormLinkListBlock = createFinalFormBlock(LinkListBlock); | ||
|
||
return ( | ||
<SaveBoundary> | ||
<FinalForm mode="edit" onSubmit={() => {}} initialValues={{ links: LinkListBlock.defaultValues() }}> | ||
<AdminComponentRoot> | ||
<Field name="links" component={FinalFormLinkListBlock} fullWidth /> | ||
</AdminComponentRoot> | ||
</FinalForm> | ||
</SaveBoundary> | ||
); | ||
}; | ||
|
||
export const BlockInFinalFormWithoutSaveBoundary = () => { | ||
const LinkListBlock = createListBlock({ name: "LinkList", block: ExternalLinkBlock }); | ||
const FinalFormLinkListBlock = createFinalFormBlock(LinkListBlock); | ||
|
||
return ( | ||
<FinalForm mode="edit" onSubmit={() => {}} initialValues={{ links: LinkListBlock.defaultValues() }}> | ||
<AdminComponentRoot> | ||
<Field name="links" component={FinalFormLinkListBlock} fullWidth /> | ||
</AdminComponentRoot> | ||
</FinalForm> | ||
); | ||
}; |