fix(custom-widgets): address final v2 review feedback (#6451)

This commit is contained in:
Thomas authored and GitHub committed 2026-07-23 02:11:32 +02:00
1 parent df967751f6
commit 4f6e335f72
20 files changed
+186 -92

No files matched your search

@@ -31,7 +31,6 @@ import { cn, errorMessage } from "@/lib/utils";
import type { SubmitInput } from "./useWorkshop";
import { ScreenshotEditor } from "./ScreenshotEditor";
import { getJsonImportSubmissionType } from "./submission-import";
interface Props {
onClose: () => void;
@@ -105,7 +104,7 @@ export const SubmitForm = ({ onClose, onSubmit }: Props) => {
const reader = new FileReader();
reader.addEventListener("load", (e) => {
const text = e.target?.result as string;
setType(getJsonImportSubmissionType(type));
setType("customWidget");
setContentAndAutofill(text, title, description);
if (step === 0) goTo(1);
});
@@ -113,7 +112,7 @@ export const SubmitForm = ({ onClose, onSubmit }: Props) => {
reader.readAsText(jsonFile);
return true;
},
[type, step, title, description, setContentAndAutofill, goTo],
[step, title, description, setContentAndAutofill, goTo],
);
const addImageFiles = useCallback(
@@ -1,13 +0,0 @@
import { describe, expect, it } from "vitest";
import { getJsonImportSubmissionType } from "./submission-import";
describe("Workshop JSON import classification", () => {
it("switches an existing Custom CSS draft to Custom Widget", () => {
expect(getJsonImportSubmissionType("customCss")).toBe("customWidget");
});
it("classifies JSON before a submission type is selected", () => {
expect(getJsonImportSubmissionType(null)).toBe("customWidget");
});
});
@@ -1,3 +0,0 @@
import type { SubmissionType } from "@site/src/lib/workshop-schema";
export const getJsonImportSubmissionType = (_currentType: SubmissionType | null): SubmissionType => "customWidget";