fix: patch cursor overflow
This commit is contained in:
8
vendor/ink-text-input/build/index.js
vendored
8
vendor/ink-text-input/build/index.js
vendored
@@ -93,12 +93,7 @@ function TextInput({ value: originalValue, placeholder = '', focus = true, mask,
|
|||||||
nextCursorWidth = input.length;
|
nextCursorWidth = input.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cursorOffset < 0) {
|
nextCursorOffset = Math.max(0, Math.min(nextCursorOffset, nextValue.length));
|
||||||
nextCursorOffset = 0;
|
|
||||||
}
|
|
||||||
if (cursorOffset > originalValue.length) {
|
|
||||||
nextCursorOffset = originalValue.length;
|
|
||||||
}
|
|
||||||
setState({ cursorOffset: nextCursorOffset, cursorWidth: nextCursorWidth });
|
setState({ cursorOffset: nextCursorOffset, cursorWidth: nextCursorWidth });
|
||||||
if (typeof onCursorOffsetChange === 'function') onCursorOffsetChange(nextCursorOffset);
|
if (typeof onCursorOffsetChange === 'function') onCursorOffsetChange(nextCursorOffset);
|
||||||
if (nextValue !== originalValue) {
|
if (nextValue !== originalValue) {
|
||||||
@@ -112,4 +107,3 @@ export function UncontrolledTextInput({ initialValue = '', ...props }) {
|
|||||||
const [value, setValue] = useState(initialValue);
|
const [value, setValue] = useState(initialValue);
|
||||||
return React.createElement(TextInput, { ...props, value: value, onChange: setValue });
|
return React.createElement(TextInput, { ...props, value: value, onChange: setValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user