fn
writeInputState
v0.0.5testedWrites value and selection back to an <input>/<textarea>. The
value is only assigned when it actually changed (avoids spurious cursor jumps),
and the caret is moved only while the element is focused so programmatic
updates never steal or reposition focus. setSelectionRange is guarded because
some input types (number, email, date) forbid it.
Example
ts
writeInputState(inputEl, { value: '(123)', selection: [5, 5] });Signature
ts
export function writeInputState(element: TextFieldElement, state: InputState): void{ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
element | TextFieldElement | The input or textarea to update |
state | InputState | The { value, selection } to apply |