MCPcopy Create free account
hub / github.com/dailydotdev/apps / onInputChange

Function onInputChange

packages/shared/src/components/fields/CodeField.tsx:37–54  ·  view source on GitHub ↗
(e: ChangeEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

35 const showCaret = isActive && code.length < length;
36
37 const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {
38 const digits = toDigits(e.target.value, length);
39 setCode(digits);
40 onChange?.(digits);
41
42 if (digits.length < length) {
43 submittedRef.current = null;
44 return;
45 }
46
47 // AutoFill can deliver a single insertion as two change events.
48 if (submittedRef.current === digits) {
49 return;
50 }
51
52 submittedRef.current = digits;
53 onSubmit(digits);
54 };
55
56 // A collapsed caret parked mid-string would scramble the order of the digits
57 // after it; a deliberate range selection (select-all, drag) stays native.

Callers

nothing calls this directly

Calls 3

toDigitsFunction · 0.85
onChangeFunction · 0.70
onSubmitFunction · 0.50

Tested by

no test coverage detected