Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix CodeBlock component allowing users to backspace content when it should be readonly (#35119)

Joshen Lim566cc3ea7550
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx
index 294a65efe43..879ffd756e4 100644
--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx
+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx
@@ -9,6 +9,7 @@ import { CronJob } from 'data/database-cron-jobs/database-cron-jobs-query'
import { useCronJobRunQuery } from 'data/database-cron-jobs/database-cron-jobs-run-query'
import { useDatabaseCronJobToggleMutation } from 'data/database-cron-jobs/database-cron-jobs-toggle-mutation'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import {
Badge,
Button,
@@ -26,7 +27,6 @@ import { TimestampInfo } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { convertCronToString, getNextRun } from './CronJobs.utils'
-import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
interface CronJobCardProps {
job: CronJob
diff --git a/packages/ui/src/components/CodeBlock/CodeBlock.tsx b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
index ccf629e76c1..fd59454f9df 100644
--- a/packages/ui/src/components/CodeBlock/CodeBlock.tsx
+++ b/packages/ui/src/components/CodeBlock/CodeBlock.tsx
@@ -168,9 +168,9 @@ export const CodeBlock = ({
>
{/* @ts-ignore */}
<SyntaxHighlighter
+ suppressContentEditableWarning
language={lang}
wrapLines={wrapLines}
- // @ts-ignore
style={monokaiTheme}
className={cn(
'code-block border border-surface p-4 w-full !my-0 !bg-surface-100 outline-none focus:border-foreground-lighter/50',
@@ -220,7 +220,12 @@ export const CodeBlock = ({
e.preventDefault()
return false
}}
- suppressContentEditableWarning={true}
+ onKeyDown={(e: any) => {
+ if (e.code === 'Backspace') {
+ e.preventDefault()
+ return false
+ }
+ }}
>
{codeValue}
</SyntaxHighlighter>