Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableEdgeToEdge hides EditText/TextField on MessagesScreen [Compose] #5304

Closed
mtali opened this issue Jun 23, 2024 · 5 comments · Fixed by #5386
Closed

enableEdgeToEdge hides EditText/TextField on MessagesScreen [Compose] #5304

mtali opened this issue Jun 23, 2024 · 5 comments · Fixed by #5386
Labels
bug Something isn't working PR Created

Comments

@mtali
Copy link

mtali commented Jun 23, 2024

Describe the bug
When edgeToEdge is enabled, the keyboard hides the input EditText/TextField in MessageActivity, making it difficult for users to see what they are typing.

SDK version

  • 6.4.0 (Stream Chat SDK)

To Reproduce
Steps to reproduce the behavior:

  1. Go to MessageActivity.
  2. Enable edgeToEdge in the onCreate method.
  3. Focus on the EditText/TextField to bring up the keyboard.
  4. Observe that the keyboard hides the input field.

Expected behavior
When the keyboard is displayed, the EditText/TextField should remain visible, adjusting the layout so that users can see what they are typing.

Device:

  • Vendor and model: Oppo CPH2461
  • Android version: 14

Code Snippet

class MessageActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    enableEdgeToEdge() // <------------------- REMOVING THIS FIXES THE ISSUE BUT I NEED IT
    val extras = checkNotNull(intent.extras)
    val channelId = extras.getString(CHANNEL_ID_KEY) ?: error("Null channelId")

    setContent {
      ChatTheme {
        Scaffold { innerPadding ->
          Box(modifier = Modifier.padding(innerPadding)) {
            MessagesScreen(
              viewModelFactory = MessagesViewModelFactory(
                context = this@MessageActivity,
                channelId = channelId,
                messageLimit = 30,
              ),
              onBackPressed = { onBackPressedDispatcher.onBackPressed() },
            )
          }
        }
      }
    }
  }

  companion object {
    private const val CHANNEL_ID_KEY = "channelId"

    fun launch(context: Context, channelId: String) {
      val intent = Intent(context, MessageActivity::class.java)
      intent.putExtra(CHANNEL_ID_KEY, channelId)
      context.startActivity(intent)
    }
  }
}

AndroidManifest.xml

<activity
  android:name=".chat.MessageActivity"
  android:exported="false"
  android:windowSoftInputMode="adjustResize"
/>

Build Configuration

const val COMPILE_SDK = 34
const val TARGET_SDK = 34
const val MIN_SDK = 27

Screenshots

  • This is when you have enableEdgeToEdge() enabled

WhatsApp Image 2024-06-23 at 23 45 52

  • This is when you don't have enableEdgeToEdge()

WhatsApp Image 2024-06-23 at 23 49 29

@mtali mtali added the bug Something isn't working label Jun 23, 2024
@mtali
Copy link
Author

mtali commented Jun 23, 2024

I have also tried adding enableEdgeToEdge() on BaseConnectedActivity here stream-chat-android-compose-sample, same thing happens

@aleksandar-apostolov
Copy link
Collaborator

Hey @mtali thank you for the report, we already looking into this, will keep you posted.

@mtali mtali closed this as completed Jun 26, 2024
@mtali mtali reopened this Jun 26, 2024
@mtali
Copy link
Author

mtali commented Jun 26, 2024

Hello @aleksandar-apostolov , thanks for your response. After some digging I found out that the solution is to add .imePadding() on MessageInput. I also think a good idea to add some safe padding on MessageInput (Maybe)

MessageInput(
        modifier = Modifier
          .fillMaxWidth()
          .imePadding()
          .weight(7f)
          .padding(start = 8.dp)

@kanat
Copy link
Collaborator

kanat commented Aug 29, 2024

Hi @mtali,

This issue was addressed in the following PR:

It will be available with the next upcoming release 👍

@kanat kanat linked a pull request Aug 29, 2024 that will close this issue
16 tasks
@kanat
Copy link
Collaborator

kanat commented Sep 5, 2024

Fixed in v6.5.0

@kanat kanat closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR Created
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants