Skip to content

Commit

Permalink
Fix crash when opening Create Contact screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Nov 28, 2023
1 parent 94873ec commit 8ffb17e
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -150,7 +151,12 @@ fun ContactScreen(
FormsInput(
modifier = Modifier
.focusRequester(focusRequester)
.padding(horizontal = 16.dp),
.padding(horizontal = 16.dp)
.onGloballyPositioned {
if (uiState.focusOnContactName) {
focusRequester.requestFocus()
}
},
initial = viewModel.contact.name,
pasteEnabled = false,
state = uiState.error?.let { DataState.Error(it) },
Expand Down Expand Up @@ -178,11 +184,6 @@ fun ContactScreen(
}
}
}
LaunchedEffect(key1 = uiState.focusOnContactName) {
if (uiState.focusOnContactName) {
focusRequester.requestFocus()
}
}
}

@Composable
Expand Down

0 comments on commit 8ffb17e

Please sign in to comment.