Fix selection changing

This commit is contained in:
Brandon Presley 2022-08-07 15:09:45 +12:00
parent 31c6047c9c
commit 1b2c26e36c
1 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,10 @@ export default function SetForm({
const [created, setCreated] = useState(new Date(set.created));
const [unit, setUnit] = useState(set.unit);
const [showDate, setShowDate] = useState(false);
const [selection, setSelection] = useState({
start: 0,
end: set.reps.toString().length,
});
const weightRef = useRef<any>(null);
const onConfirm = (date: Date) => {
@ -52,8 +56,11 @@ export default function SetForm({
value={reps}
onChangeText={setReps}
onSubmitEditing={() => weightRef.current?.focus()}
selection={{start: 0, end: set.reps.toString().length}}
selection={selection}
onSelectionChange={e => setSelection(e.nativeEvent.selection)}
autoFocus
selectTextOnFocus
blurOnSubmit={false}
/>
<TextInput
style={styles.marginBottom}