Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Don't throw error in FormPreview if assetDatabase is not a UUID #9531

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import React from "react";
import { type WidgetProps } from "@rjsf/utils";
import RichTextEditor from "@/components/richTextEditor/RichTextEditor";
import { validateUUID } from "@/types/helpers";
import {isUUID} from "@/types/helpers";

const RichTextWidget: React.FunctionComponent<WidgetProps> = ({
id,
Expand All @@ -45,7 +45,7 @@ const RichTextWidget: React.FunctionComponent<WidgetProps> = ({
onBlur(id, editor.getHTML());
}}
editable={!(disabled || readonly)}
assetDatabaseId={validateUUID(database)}
assetDatabaseId={typeof database === "string" && isUUID(database) ? database : null}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a comment that the database will be an object in the preview when a variable is provided?

content={typeof value === "string" ? value : ""}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import ErrorToast from "@/components/richTextEditor/ErrorToast";

type EditorProps = EditorProviderProps & {
// A PixieBrix asset database ID to use for uploading images. If not included, the image extension will be disabled.
assetDatabaseId?: UUID;
assetDatabaseId?: UUID | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to need both ? and | null? You could just pass undefined instead of null?

};

interface ImageWithAssetDatabaseOptions extends ImageOptions {
Expand Down
Loading