오류 상황

낱말 맞추기 퀴즈를 구현하며, 컴포넌트가 키보드에 가려지는 상황이 발생하였다.

ezgif-6-56f4567561.gif

아래는 낱말 컴포넌트의 코드이다.


@Composable
fun ConsumeBlankContentUi(
    word: String,
    index: Int = 0,
    onContentRemove: (Int) -> Unit,
    removeIconVisible: Boolean = true,
    onValueChanged: (String, Int) -> Unit,
    textFieldEnabled: Boolean = true,
    clickableEnabled: Boolean = true,
) {
    Row(
        modifier = Modifier
            .shadow(
                elevation = 10.dp,
                shape = RoundedCornerShape(4.dp),
                clip = false,
            )
            .background(
                color = Color.White,
                shape = RoundedCornerShape(4.dp),
            )
            .clickable(
                enabled = clickableEnabled,
                onClick = { onContentRemove(index) },
            )
            .padding(10.dp),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.spacedBy(8.dp),
    ) {

        BasicTextField(
            value = word,
            onValueChange = { newValue ->
                onValueChanged(newValue, index)
            },
            modifier = Modifier
                .width(IntrinsicSize.Min),
            enabled = textFieldEnabled,
        )
        if (removeIconVisible) {
            Icon(
                imageVector = Icons.Outlined.Cancel,
                contentDescription = stringResource(R.string.des_remove_blank),
                tint = MaterialTheme.colorScheme.onSurfaceVariant,
            )
        }
    }
}

문제 해결이 안되는 사태 발생

키보드에 의해 화면이 가려지는 오류를 해결하는 방법을 적용해도 해결이 되지 않았다.

문제 해결 과정

문제를 해결하기 위해 component tree를 활용한 분석을 진행하였다.

image.png

image.png

예상이 맞는지 확인하기 위해 검증을 진행하였다.