Skip to content

Commit 98ea683

Browse files
committed
enable debounced validation
1 parent 8fa32b2 commit 98ea683

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

site/src/pages/TemplatePage/TemplateEmbedPage/TemplateEmbedPage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Input } from "components/Input/Input";
99
import { Label } from "components/Label/Label";
1010
import { Loader } from "components/Loader/Loader";
1111
import { RichParameterInput } from "components/RichParameterInput/RichParameterInput";
12+
import { useDebouncedFunction } from "hooks/debounce";
1213
import { useClipboard } from "hooks/useClipboard";
1314
import { CheckIcon, CopyIcon } from "lucide-react";
1415
import { useTemplateLayoutContext } from "pages/TemplatePage/TemplateLayout";
@@ -112,6 +113,10 @@ export const TemplateEmbedPageView: FC<TemplateEmbedPageViewProps> = ({
112113
}
113114
}
114115
};
116+
const { debounced: debouncedValidateWorkspaceName } = useDebouncedFunction(
117+
validateWorkspaceName,
118+
500,
119+
);
115120

116121
const hookId = useId();
117122
const defaultWorkspaceNameID = `${hookId}-default-workspace-name`;
@@ -164,7 +169,7 @@ export const TemplateEmbedPageView: FC<TemplateEmbedPageViewProps> = ({
164169
id={defaultWorkspaceNameID}
165170
value={buttonValues.name}
166171
onChange={(event) => {
167-
validateWorkspaceName(event.target.value);
172+
debouncedValidateWorkspaceName(event.target.value);
168173
setButtonValues((buttonValues) => ({
169174
...buttonValues,
170175
name: event.target.value,

0 commit comments

Comments
 (0)