From 73b0501a31fa41e688831c60ce8dc771e77c84d5 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 12 Feb 2024 17:44:06 +0800 Subject: [PATCH] prevent setting selection bigger than the length --- src/pages/iou/steps/MoneyRequestAmountForm.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.js b/src/pages/iou/steps/MoneyRequestAmountForm.js index 0722bf3f6d41..9106ff28589e 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.js +++ b/src/pages/iou/steps/MoneyRequestAmountForm.js @@ -296,7 +296,10 @@ function MoneyRequestAmountForm({amount, taxAmount, currency, isEditing, forward if (!shouldUpdateSelection) { return; } - setSelection(e.nativeEvent.selection); + const maxSelection = formattedAmount.length; + const start = Math.min(e.nativeEvent.selection.start, maxSelection); + const end = Math.min(e.nativeEvent.selection.end, maxSelection); + setSelection({start, end}); }} onKeyPress={textInputKeyPress} />