MCPcopy Create free account
hub / github.com/UI5/webcomponents / setCaretPosition

Function setCaretPosition

packages/base/src/util/Caret.ts:16–23  ·  view source on GitHub ↗
(field: HTMLInputElement, caretPos: number | null)

Source from the content-addressed store, hash-verified

14};
15
16const setCaretPosition = (field: HTMLInputElement, caretPos: number | null) => {
17 if (field.selectionStart) {
18 field.focus();
19 field.setSelectionRange(caretPos, caretPos);
20 } else {
21 field.focus();
22 }
23};
24
25export {
26 getCaretPosition,

Callers 1

setCaretPositionMethod · 0.85

Calls 1

focusMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…