Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: prevent submit (#1708)

Mehdie355fa9f579b
diff --git a/packages/monaco/src/index.tsx b/packages/monaco/src/index.tsx
index 084d3ff7..b79d46a1 100644
--- a/packages/monaco/src/index.tsx
+++ b/packages/monaco/src/index.tsx
@@ -87,6 +87,14 @@ export function CodePanel(props: CodePanelProps) {
const handleSubmit = useCallback(async () => {
const hasErrors = tsErrors?.some((e) => e.length) ?? false;
+ if (disabled) {
+ toast({
+ variant: 'destructive',
+ title: 'You are unable to submit.',
+ });
+ return;
+ }
+
try {
validator(code);
// eslint-disable-next-line @typescript-eslint/no-explicit-any