TP-37022 Cursor not moving to next field in DOB input in some devices (#143)
This commit is contained in:
@@ -73,7 +73,6 @@ class MultiSectionTextFieldRenderer() : Renderer<MultiSectionTextFieldProperty>
|
||||
multiSectionTextFieldData =
|
||||
multiSectionTextFieldData?.copyNonNull(dataState.value) ?: dataState.value
|
||||
}
|
||||
|
||||
var inputText by remember {
|
||||
mutableStateOf(multiSectionTextFieldData?.inputText.orEmpty())
|
||||
}
|
||||
@@ -113,9 +112,6 @@ class MultiSectionTextFieldRenderer() : Renderer<MultiSectionTextFieldProperty>
|
||||
(0 until property.textFieldPropertyList.size).map { FocusRequester() }
|
||||
}
|
||||
|
||||
var lastInput by remember {
|
||||
mutableStateOf("")
|
||||
}
|
||||
if (property.visible.orTrue()) {
|
||||
Column(
|
||||
modifier = (modifier ?: Modifier)
|
||||
@@ -170,12 +166,25 @@ class MultiSectionTextFieldRenderer() : Renderer<MultiSectionTextFieldProperty>
|
||||
onValueChange = { value ->
|
||||
cursorPosition = value.selection.start
|
||||
if (value.text.isDigitsOnly()) {
|
||||
if (maxCharList[index] >= value.text.length) {
|
||||
if (maxCharList[index] > value.text.length) {
|
||||
inputValues[index].value = value
|
||||
} else if (maxCharList[index] == value.text.length) {
|
||||
if (value.text.compareTo(inputValues[index].value.text) != 0 && focusRequesters.getOrNull(index)?.freeFocus() == true) {
|
||||
focusRequesters.getOrNull(index+1)?.requestFocus()
|
||||
}
|
||||
inputValues[index].value = value
|
||||
lastInput = ""
|
||||
} else {
|
||||
if (cursorPosition == maxCharList[index] + 1) {
|
||||
lastInput = value.text[maxCharList[index]].toString()
|
||||
val lastInput = value.text[maxCharList[index]].toString()
|
||||
if (index < property.textFieldPropertyList.size - 1 && maxCharList[index + 1] > inputValues[index + 1].value.text.length && inputValues[index + 1].value.text.isEmpty()) {
|
||||
inputValues[index + 1].value = TextFieldValue(
|
||||
text = lastInput + inputValues[index + 1].value.text,
|
||||
selection = TextRange(maxCharList[index + 1])
|
||||
)
|
||||
}
|
||||
}
|
||||
if (focusRequesters.getOrNull(index)?.freeFocus() == true) {
|
||||
focusRequesters.getOrNull(index+1)?.requestFocus()
|
||||
}
|
||||
}
|
||||
doOnValueChange(
|
||||
@@ -203,23 +212,10 @@ class MultiSectionTextFieldRenderer() : Renderer<MultiSectionTextFieldProperty>
|
||||
.onKeyEvent { event ->
|
||||
val cellValue = inputValues[index].value
|
||||
if (event.type == KeyEventType.KeyUp) {
|
||||
val maxChar =
|
||||
property.textFieldPropertyList.getOrNull(index)?.maxChar
|
||||
?: defaultMaxCharList[index]
|
||||
if (event.key == Key.Backspace && cellValue.text.isEmpty()) {
|
||||
focusRequesters
|
||||
.getOrNull(index - 1)
|
||||
?.requestFocus()
|
||||
} else if (event.key != Key.Backspace && cellValue.text.length.compareTo(maxChar) == 0) {
|
||||
focusRequesters
|
||||
.getOrNull(index + 1)
|
||||
?.requestFocus()
|
||||
if (index < property.textFieldPropertyList.size - 1 && maxCharList[index + 1] > inputValues[index + 1].value.text.length && inputValues[index + 1].value.text.isEmpty()) {
|
||||
inputValues[index + 1].value = TextFieldValue(
|
||||
text = lastInput + inputValues[index + 1].value.text,
|
||||
selection = TextRange(maxCharList[index + 1])
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user