Skip to content

Commit 87e0b8e

Browse files
committed
refact: added autoComplete and spellCheck to off
1 parent 29ca8a3 commit 87e0b8e

7 files changed

Lines changed: 33 additions & 8 deletions

File tree

src/components/ui/input.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import * as React from "react"
22

33
import { cn } from "@/lib/utils"
44

5-
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
5+
function Input({ className, type, autoComplete = "off", spellCheck = false, ...props }: React.ComponentProps<"input">) {
66
return (
77
<input
88
type={type}
9+
autoComplete={autoComplete}
10+
spellCheck={spellCheck}
911
data-slot="input"
1012
className={cn(
1113
"file:text-foreground placeholder:text-muted-foreground/70 selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-background/45 px-3 py-1 text-base shadow-xs transition-[color,box-shadow,border-color,background-color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",

src/components/ui/textarea.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import * as React from "react"
22

33
import { cn } from "@/lib/utils"
44

5-
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
5+
function Textarea({ className, autoComplete = "off", spellCheck = false, ...props }: React.ComponentProps<"textarea">) {
66
return (
77
<textarea
8+
autoComplete={autoComplete}
9+
spellCheck={spellCheck}
810
data-slot="textarea"
911
className={cn(
1012
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",

src/features/schema-explorer/components/AddIndexesDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default function AddIndexesDialog({
4141
indexes,
4242
isSubmitting }
4343
= useAddIndexDialog({
44+
open,
4445
onOpenChange,
4546
dbId,
4647
schemaName,

src/features/schema-explorer/hooks/useAddIndexDialog.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { CreateIndexDefinition } from "@/features/database/types";
22
import { databaseService } from "@/services/bridge/database";
3-
import { useState } from "react";
3+
import { useState, useEffect } from "react";
44
import { toast } from "sonner";
55

66

77
interface AddIndexesDialogProps {
8+
open: boolean;
89
onOpenChange: (open: boolean) => void;
910
dbId: string;
1011
schemaName: string;
@@ -13,14 +14,20 @@ interface AddIndexesDialogProps {
1314
}
1415

1516

16-
export function useAddIndexDialog({ onOpenChange, dbId, schemaName, tableName, onSuccess }: AddIndexesDialogProps) {
17+
export function useAddIndexDialog({ open, onOpenChange, dbId, schemaName, tableName, onSuccess }: AddIndexesDialogProps) {
1718
const [indexes, setIndexes] = useState<CreateIndexDefinition[]>([]);
1819
const [isSubmitting, setIsSubmitting] = useState(false);
1920

2021
const resetForm = () => {
2122
setIndexes([]);
2223
};
2324

25+
useEffect(() => {
26+
if (open) {
27+
resetForm();
28+
}
29+
}, [open]);
30+
2431
const handleClose = () => {
2532
if (!isSubmitting) {
2633
resetForm();

src/features/schema-explorer/hooks/useAlterTableDialog.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AlterTableOperation } from "@/features/database/types";
22
import { migrationService } from "@/services/bridge/migration";
3-
import { useState } from "react";
3+
import { useState, useEffect } from "react";
44
import { toast } from "sonner";
55

66

@@ -17,14 +17,20 @@ interface AlterTableDialogProps {
1717

1818

1919

20-
export function useAlterTableDialog({ onOpenChange, dbId, schemaName, tableName, onSuccess }: AlterTableDialogProps) {
20+
export function useAlterTableDialog({ open, onOpenChange, dbId, schemaName, tableName, onSuccess }: AlterTableDialogProps) {
2121
const [operations, setOperations] = useState<AlterTableOperation[]>([]);
2222
const [isSubmitting, setIsSubmitting] = useState(false);
2323

2424
const resetForm = () => {
2525
setOperations([]);
2626
};
2727

28+
useEffect(() => {
29+
if (open) {
30+
resetForm();
31+
}
32+
}, [open]);
33+
2834
const handleClose = () => {
2935
if (!isSubmitting) {
3036
resetForm();

src/features/schema-explorer/hooks/useCreateTableDialog.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function useCreateTableDialog({ onOpenChange, dbId, schemaName, onSuccess
2828
useEffect(() => {
2929
if (open && dbId) {
3030
fetchAvailableTables();
31+
resetForm();
3132
}
3233
}, [open, dbId]);
3334

src/features/schema-explorer/hooks/useDropTableDialog.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DropMode } from "@/features/database/types";
22
import { migrationService } from "@/services/bridge/migration";
3-
import { useState } from "react";
3+
import { useState, useEffect } from "react";
44
import { toast } from "sonner";
55

66
interface DropTableDialogProps {
@@ -13,7 +13,7 @@ interface DropTableDialogProps {
1313
}
1414

1515

16-
export default function useDropTableDialog({ onOpenChange, dbId, schemaName, tableName, onSuccess }: DropTableDialogProps) {
16+
export default function useDropTableDialog({ open, onOpenChange, dbId, schemaName, tableName, onSuccess }: DropTableDialogProps) {
1717
const [mode, setMode] = useState<DropMode>("RESTRICT");
1818
const [confirmText, setConfirmText] = useState("");
1919
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -23,6 +23,12 @@ export default function useDropTableDialog({ onOpenChange, dbId, schemaName, tab
2323
setConfirmText("");
2424
};
2525

26+
useEffect(() => {
27+
if (open) {
28+
resetForm();
29+
}
30+
}, [open]);
31+
2632
const handleClose = () => {
2733
if (!isSubmitting) {
2834
resetForm();

0 commit comments

Comments
 (0)