Skip to content

Commit

Permalink
Os/focuseable before focus requester (#5)
Browse files Browse the repository at this point in the history
* inverting the order of focusable and focus requester to fix the behavior

* inverting the order of focusable and focus requester to fix the behavior
  • Loading branch information
omarsanchezv authored Mar 22, 2023
1 parent 0153435 commit c89bb00
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ fun TogiCountryCodePicker(
OutlinedTextField(
modifier = modifier
.fillMaxWidth()
.focusRequester(focusRequester = focusRequester)
.focusable()
.autofill(
autofillTypes = listOf(AutofillType.PhoneNumberNational),
onFill = { phoneNumber = it },
focusRequester = focusRequester,
)
.focusable(),
.focusRequester(focusRequester = focusRequester),
shape = shape,
value = phoneNumber,
onValueChange = {
Expand Down Expand Up @@ -134,9 +134,11 @@ fun TogiCountryCodePicker(
keyboardType = KeyboardType.Phone,
autoCorrect = true,
),
keyboardActions = KeyboardActions(onDone = {
keyboardController?.hideSoftwareKeyboard()
}),
keyboardActions = KeyboardActions(
onDone = {
keyboardController?.hideSoftwareKeyboard()
},
),
leadingIcon = {
TogiCodeDialog(
onCountryChange = {
Expand Down Expand Up @@ -201,17 +203,17 @@ fun Modifier.autofill(
LocalAutofillTree.current += autofillNode

this.onGloballyPositioned {
autofillNode.boundingBox = it.boundsInWindow()
focusRequester.requestFocus()
}.onFocusChanged { focusState ->
autofill?.run {
if (focusState.isFocused) {
requestAutofillForNode(autofillNode)
} else {
cancelAutofillForNode(autofillNode)
autofillNode.boundingBox = it.boundsInWindow()
focusRequester.requestFocus()
}.onFocusChanged { focusState ->
autofill?.run {
if (focusState.isFocused) {
requestAutofillForNode(autofillNode)
} else {
cancelAutofillForNode(autofillNode)
}
}
}
}
}

@Preview
Expand Down

0 comments on commit c89bb00

Please sign in to comment.