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

Function keepCaretAtEnd

packages/shared/src/components/fields/CodeField.tsx:58–71  ·  view source on GitHub ↗
(e: SyntheticEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

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.
58 const keepCaretAtEnd = (e: SyntheticEvent<HTMLInputElement>) => {
59 const input = e.currentTarget;
60 const end = input.value.length;
61
62 if (input.selectionStart !== input.selectionEnd) {
63 return;
64 }
65
66 if (input.selectionStart === end) {
67 return;
68 }
69
70 input.setSelectionRange(end, end);
71 };
72
73 return (
74 <div className="relative flex flex-row gap-2">

Callers 1

CodeFieldFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected