Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: use DialogActions consistently in all dialogs with footer buttons (#5701)

Oleg Isonen5c6af9942bed
diff --git a/apps/builder/app/builder/features/breakpoints/confirmation-dialog.tsx b/apps/builder/app/builder/features/breakpoints/confirmation-dialog.tsx
index bf7fcc589b..0154dbaa10 100644
--- a/apps/builder/app/builder/features/breakpoints/confirmation-dialog.tsx
+++ b/apps/builder/app/builder/features/breakpoints/confirmation-dialog.tsx
@@ -35,12 +35,12 @@ export const ConfirmationDialog = ({
</Text>
</Flex>
<DialogActions>
+ <Button autoFocus onClick={onConfirm} color="destructive">
+ Delete
+ </Button>
<Button color="neutral" onClick={onAbort}>
Cancel
</Button>
- <Button onClick={onConfirm} color="destructive">
- Delete
- </Button>
</DialogActions>
</DialogContent>
</Dialog>
diff --git a/apps/builder/app/builder/features/pages/confirmation-dialogs.tsx b/apps/builder/app/builder/features/pages/confirmation-dialogs.tsx
index 6a392c0450..3f1eb37432 100644
--- a/apps/builder/app/builder/features/pages/confirmation-dialogs.tsx
+++ b/apps/builder/app/builder/features/pages/confirmation-dialogs.tsx
@@ -1,5 +1,6 @@
import {
Dialog,
+ DialogActions,
DialogContent,
DialogTitle,
DialogClose,
@@ -38,22 +39,23 @@ export const DeletePageConfirmationDialog = ({
You can undo it even if you delete the page as long as you don't
reload.
</Text>
- <Flex direction="rowReverse" gap="2">
- <DialogClose>
- <Button
- color="destructive"
- onClick={() => {
- onConfirm();
- }}
- >
- Delete Page
- </Button>
- </DialogClose>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <DialogClose>
+ <Button
+ autoFocus
+ color="destructive"
+ onClick={() => {
+ onConfirm();
+ }}
+ >
+ Delete Page
+ </Button>
+ </DialogClose>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
@@ -83,22 +85,23 @@ export const DeleteFolderConfirmationDialog = ({
<DialogTitle>Delete confirmation</DialogTitle>
<Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
<Text>{`Delete folder "${folder.name}" including all of its pages?`}</Text>
- <Flex direction="rowReverse" gap="2">
- <DialogClose>
- <Button
- color="destructive"
- onClick={() => {
- onConfirm();
- }}
- >
- Delete
- </Button>
- </DialogClose>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <DialogClose>
+ <Button
+ autoFocus
+ color="destructive"
+ onClick={() => {
+ onConfirm();
+ }}
+ >
+ Delete
+ </Button>
+ </DialogClose>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
diff --git a/apps/builder/app/builder/shared/asset-manager/delete-unused-assets.tsx b/apps/builder/app/builder/shared/asset-manager/delete-unused-assets.tsx
index 05f46be057..85cbf5a5eb 100644
--- a/apps/builder/app/builder/shared/asset-manager/delete-unused-assets.tsx
+++ b/apps/builder/app/builder/shared/asset-manager/delete-unused-assets.tsx
@@ -2,6 +2,7 @@ import { atom } from "nanostores";
import { useStore } from "@nanostores/react";
import {
Dialog,
+ DialogActions,
DialogContent,
DialogTitle,
DialogClose,
@@ -51,30 +52,32 @@ const DeleteUnusedAssetsDialogContent = ({
const unusedAssets = getUnusedAssets();
return (
- <Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
- {unusedAssets.length === 0 ? (
- <Text>There are no unused assets to delete.</Text>
- ) : (
- <>
- <Text>
- Delete {unusedAssets.length} unused{" "}
- {unusedAssets.length === 1 ? "asset" : "assets"} from the project?
- </Text>
+ <>
+ <Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
+ {unusedAssets.length === 0 ? (
+ <Text>There are no unused assets to delete.</Text>
+ ) : (
+ <>
+ <Text>
+ Delete {unusedAssets.length} unused{" "}
+ {unusedAssets.length === 1 ? "asset" : "assets"} from the project?
+ </Text>
- <ScrollArea>
- <Box css={{ maxHeight: 200 }}>
- <Flex direction="column" gap="1">
- {unusedAssets.map((asset) => (
- <Text key={asset.id} variant="mono" truncate>
- {formatAssetName(asset)}
- </Text>
- ))}
- </Flex>
- </Box>
- </ScrollArea>
- </>
- )}
- <Flex direction="rowReverse" gap="2">
+ <ScrollArea>
+ <Box css={{ maxHeight: 200 }}>
+ <Flex direction="column" gap="1">
+ {unusedAssets.map((asset) => (
+ <Text key={asset.id} variant="mono" truncate>
+ {formatAssetName(asset)}
+ </Text>
+ ))}
+ </Flex>
+ </Box>
+ </ScrollArea>
+ </>
+ )}
+ </Flex>
+ <DialogActions>
{unusedAssets.length > 0 && (
<Button
color="destructive"
@@ -96,8 +99,8 @@ const DeleteUnusedAssetsDialogContent = ({
{unusedAssets.length > 0 ? "Cancel" : "Close"}
</Button>
</DialogClose>
- </Flex>
- </Flex>
+ </DialogActions>
+ </>
);
};
diff --git a/apps/builder/app/builder/shared/css-variable-utils.tsx b/apps/builder/app/builder/shared/css-variable-utils.tsx
index 78a2f7c2f0..d7b2dab6e6 100644
--- a/apps/builder/app/builder/shared/css-variable-utils.tsx
+++ b/apps/builder/app/builder/shared/css-variable-utils.tsx
@@ -3,6 +3,7 @@ import { atom, computed } from "nanostores";
import { useStore } from "@nanostores/react";
import {
Dialog,
+ DialogActions,
DialogContent,
DialogTitle,
DialogClose,
@@ -501,21 +502,21 @@ export const DeleteCssVariableDialog = ({
<DialogTitle>Delete confirmation</DialogTitle>
<Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
<Text>{`Delete CSS variable "${cssVariable?.property}" from the project?`}</Text>
- <Flex direction="rowReverse" gap="2">
- <Button
- color="destructive"
- onClick={() => {
- onConfirm(cssVariable!.property);
- onClose();
- }}
- >
- Delete
- </Button>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <Button
+ color="destructive"
+ onClick={() => {
+ onConfirm(cssVariable!.property);
+ onClose();
+ }}
+ >
+ Delete
+ </Button>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
@@ -588,15 +589,15 @@ export const RenameCssVariableDialog = ({
</Text>
)}
</Flex>
- <Flex direction="rowReverse" gap="2">
- <Button color="primary" onClick={handleConfirm}>
- Rename
- </Button>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <Button color="primary" onClick={handleConfirm}>
+ Rename
+ </Button>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
@@ -612,31 +613,33 @@ const DeleteUnusedCssVariablesDialogContent = ({
const unusedVariablesArray = Array.from(unusedVariables);
return (
- <Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
- {unusedVariablesArray.length === 0 ? (
- <Text>There are no unused CSS variables to delete.</Text>
- ) : (
- <>
- <Text>
- Delete {unusedVariablesArray.length} unused CSS{" "}
- {unusedVariablesArray.length === 1 ? "variable" : "variables"} from
- the project?
- </Text>
- <Text
- variant="mono"
- css={{
- maxHeight: 200,
- overflowY: "auto",
- backgroundColor: theme.colors.backgroundPanel,
- borderRadius: theme.borderRadius[4],
- wordBreak: "break-word",
- }}
- >
- {unusedVariablesArray.join(", ")}
- </Text>
- </>
- )}
- <Flex direction="rowReverse" gap="2">
+ <>
+ <Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
+ {unusedVariablesArray.length === 0 ? (
+ <Text>There are no unused CSS variables to delete.</Text>
+ ) : (
+ <>
+ <Text>
+ Delete {unusedVariablesArray.length} unused CSS{" "}
+ {unusedVariablesArray.length === 1 ? "variable" : "variables"}{" "}
+ from the project?
+ </Text>
+ <Text
+ variant="mono"
+ css={{
+ maxHeight: 200,
+ overflowY: "auto",
+ backgroundColor: theme.colors.backgroundPanel,
+ borderRadius: theme.borderRadius[4],
+ wordBreak: "break-word",
+ }}
+ >
+ {unusedVariablesArray.join(", ")}
+ </Text>
+ </>
+ )}
+ </Flex>
+ <DialogActions>
{unusedVariablesArray.length > 0 && (
<Button
color="destructive"
@@ -661,8 +664,8 @@ const DeleteUnusedCssVariablesDialogContent = ({
{unusedVariablesArray.length > 0 ? "Cancel" : "Close"}
</Button>
</DialogClose>
- </Flex>
- </Flex>
+ </DialogActions>
+ </>
);
};
diff --git a/apps/builder/app/builder/shared/data-variable-utils.tsx b/apps/builder/app/builder/shared/data-variable-utils.tsx
index caaa828274..8993905c8e 100644
--- a/apps/builder/app/builder/shared/data-variable-utils.tsx
+++ b/apps/builder/app/builder/shared/data-variable-utils.tsx
@@ -4,6 +4,7 @@ import { useStore } from "@nanostores/react";
import { toast } from "@webstudio-is/design-system";
import {
Dialog,
+ DialogActions,
DialogContent,
DialogTitle,
DialogClose,
@@ -88,21 +89,22 @@ export const DeleteDataVariableDialog = ({
? `Delete "${variable.name}" variable from the project? It is used in ${variable.usages} ${variable.usages === 1 ? "expression" : "expressions"}.`
: `Delete "${variable.name}" variable from the project?`)}
</Text>
- <Flex direction="rowReverse" gap="2">
- <Button
- color="destructive"
- onClick={() => {
- onConfirm(variable!.id);
- onClose();
- }}
- >
- Delete
- </Button>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <Button
+ autoFocus
+ color="destructive"
+ onClick={() => {
+ onConfirm(variable!.id);
+ onClose();
+ }}
+ >
+ Delete
+ </Button>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
@@ -262,15 +264,15 @@ export const RenameDataVariableDialog = ({
</Text>
)}
</Flex>
- <Flex direction="rowReverse" gap="2">
- <Button color="primary" onClick={handleConfirm}>
- Rename
- </Button>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <Button color="primary" onClick={handleConfirm}>
+ Rename
+ </Button>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
@@ -334,33 +336,33 @@ export const DeleteUnusedDataVariablesDialog = () => {
</Text>
</>
)}
- <Flex direction="rowReverse" gap="2">
- {unusedVariables.length > 0 && (
- <Button
- color="destructive"
- autoFocus
- onClick={() => {
- const deletedCount = deleteUnusedDataVariables();
- handleClose();
- if (deletedCount === 0) {
- toast.info("No unused data variables to delete");
- } else {
- toast.success(
- `Deleted ${deletedCount} unused data ${deletedCount === 1 ? "variable" : "variables"}`
- );
- }
- }}
- >
- Delete
- </Button>
- )}
- <DialogClose>
- <Button color="ghost">
- {unusedVariables.length > 0 ? "Cancel" : "Close"}
- </Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ {unusedVariables.length > 0 && (
+ <Button
+ color="destructive"
+ autoFocus
+ onClick={() => {
+ const deletedCount = deleteUnusedDataVariables();
+ handleClose();
+ if (deletedCount === 0) {
+ toast.info("No unused data variables to delete");
+ } else {
+ toast.success(
+ `Deleted ${deletedCount} unused data ${deletedCount === 1 ? "variable" : "variables"}`
+ );
+ }
+ }}
+ >
+ Delete
+ </Button>
+ )}
+ <DialogClose>
+ <Button color="ghost">
+ {unusedVariables.length > 0 ? "Cancel" : "Close"}
+ </Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
diff --git a/apps/builder/app/builder/shared/style-source-actions.tsx b/apps/builder/app/builder/shared/style-source-actions.tsx
index 879b1198a4..0864ff00b3 100644
--- a/apps/builder/app/builder/shared/style-source-actions.tsx
+++ b/apps/builder/app/builder/shared/style-source-actions.tsx
@@ -3,6 +3,7 @@ import { atom, computed } from "nanostores";
import { useStore } from "@nanostores/react";
import {
Dialog,
+ DialogActions,
DialogContent,
DialogTitle,
DialogClose,
@@ -159,21 +160,22 @@ export const DeleteStyleSourceDialog = ({
<DialogTitle>Delete confirmation</DialogTitle>
<Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
<Text>{`Delete "${styleSource?.name}" token from the project including all of its styles?`}</Text>
- <Flex direction="rowReverse" gap="2">
- <Button
- color="destructive"
- onClick={() => {
- onConfirm(styleSource!.id);
- onClose();
- }}
- >
- Delete
- </Button>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <Button
+ autoFocus
+ color="destructive"
+ onClick={() => {
+ onConfirm(styleSource!.id);
+ onClose();
+ }}
+ >
+ Delete
+ </Button>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
@@ -250,15 +252,15 @@ export const RenameStyleSourceDialog = ({
</Text>
)}
</Flex>
- <Flex direction="rowReverse" gap="2">
- <Button color="primary" onClick={handleConfirm}>
- Rename
- </Button>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <Button color="primary" onClick={handleConfirm}>
+ Rename
+ </Button>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
@@ -322,33 +324,33 @@ export const DeleteUnusedTokensDialog = () => {
</Text>
</>
)}
- <Flex direction="rowReverse" gap="2">
- {unusedTokens.length > 0 && (
- <Button
- color="destructive"
- autoFocus
- onClick={() => {
- const deletedCount = deleteUnusedTokens();
- handleClose();
- if (deletedCount === 0) {
- toast.info("No unused tokens to delete");
- } else {
- toast.success(
- `Deleted ${deletedCount} unused ${deletedCount === 1 ? "token" : "tokens"}`
- );
- }
- }}
- >
- Delete
- </Button>
- )}
- <DialogClose>
- <Button color="ghost">
- {unusedTokens.length > 0 ? "Cancel" : "Close"}
- </Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ {unusedTokens.length > 0 && (
+ <Button
+ color="destructive"
+ autoFocus
+ onClick={() => {
+ const deletedCount = deleteUnusedTokens();
+ handleClose();
+ if (deletedCount === 0) {
+ toast.info("No unused tokens to delete");
+ } else {
+ toast.success(
+ `Deleted ${deletedCount} unused ${deletedCount === 1 ? "token" : "tokens"}`
+ );
+ }
+ }}
+ >
+ Delete
+ </Button>
+ )}
+ <DialogClose>
+ <Button color="ghost">
+ {unusedTokens.length > 0 ? "Cancel" : "Close"}
+ </Button>
+ </DialogClose>
+ </DialogActions>
</DialogContent>
</Dialog>
);
diff --git a/apps/builder/app/dashboard/projects/tags.tsx b/apps/builder/app/dashboard/projects/tags.tsx
index 360ce8d362..f57982cabb 100644
--- a/apps/builder/app/dashboard/projects/tags.tsx
+++ b/apps/builder/app/dashboard/projects/tags.tsx
@@ -53,22 +53,23 @@ const DeleteConfirmationDialog = ({
<DialogContent>
<Flex gap="3" direction="column" css={{ padding: theme.panel.padding }}>
<Text>{question}</Text>
- <Flex direction="rowReverse" gap="2">
- <DialogClose>
- <Button
- color="destructive"
- onClick={() => {
- onConfirm();
- }}
- >
- Delete
- </Button>
- </DialogClose>
- <DialogClose>
- <Button color="ghost">Cancel</Button>
- </DialogClose>
- </Flex>
</Flex>
+ <DialogActions>
+ <DialogClose>
+ <Button
+ autoFocus
+ color="destructive"
+ onClick={() => {
+ onConfirm();
+ }}
+ >
+ Delete
+ </Button>
+ </DialogClose>
+ <DialogClose>
+ <Button color="ghost">Cancel</Button>
+ </DialogClose>
+ </DialogActions>
<DialogTitle>Delete confirmation</DialogTitle>
</DialogContent>
</Dialog>
diff --git a/apps/builder/app/dashboard/workspace/manage-members-dialog.tsx b/apps/builder/app/dashboard/workspace/manage-members-dialog.tsx
index e1cf7d4660..f1809ca4cf 100644
--- a/apps/builder/app/dashboard/workspace/manage-members-dialog.tsx
+++ b/apps/builder/app/dashboard/workspace/manage-members-dialog.tsx
@@ -400,12 +400,12 @@ const ExtraSeatsConfirmDialog = ({
</Text>
</Flex>
<DialogActions>
- <Button color="neutral" onClick={onCancel}>
- Cancel
- </Button>
<Button autoFocus onClick={onConfirm}>
Confirm
</Button>
+ <Button color="neutral" onClick={onCancel}>
+ Cancel
+ </Button>
</DialogActions>
</DialogContent>
</Dialog>
diff --git a/apps/builder/app/shared/token-conflict-dialog.tsx b/apps/builder/app/shared/token-conflict-dialog.tsx
index 9b818f1115..636e6eefa0 100644
--- a/apps/builder/app/shared/token-conflict-dialog.tsx
+++ b/apps/builder/app/shared/token-conflict-dialog.tsx
@@ -210,7 +210,7 @@ export const TokenConflictDialog = () => {
</Flex>
</Flex>
<DialogActions>
- <Button color="positive" onClick={handleResolve}>
+ <Button autoFocus color="positive" onClick={handleResolve}>
Continue
</Button>
<Button color="ghost" onClick={handleCancel}>