Open History to see the last commit
1"use client";
2
3import { useCommitOnBlur } from "~/hooks/useCommitOnBlur";
4import { Input, type InputProps } from "./input";
5
6export type DraftInputProps = Omit<InputProps, "value" | "onChange" | "defaultValue"> & {
7 readonly value: string;
8 readonly onCommit: (next: string) => void;
9};
10
11/**
12 * Prevents each keystroke from triggering a settings-wide re-render or a server RPC round-trip,
13 * which otherwise makes fields backed by a server-hydrated value feel laggy.
14 */
15export function DraftInput({ value, onCommit, ...rest }: DraftInputProps) {
16 const bag = useCommitOnBlur(value, onCommit);
17 return <Input {...rest} {...bag} />;
18}