I have a login screen with two edit texts username and password. Once I fill those edit texts and I navigate to register screen using: navController.navigate(R.id.registerFragment); and when I come back to login screen using: navController.popBackStack(); the password's edit text input is getting copied and replacing the username's edit text. Can someone explain why is this happening?
The steps are simple: fill edit texts -> navigate to register screen -> back to login screen -> the password edit text input has been pasted to the username edit text input.
This image shows the first time I edit the edit texts:

This image shows the same edit texts, but after I came back from the register screen, where I have been navigated using the register now red text.

For example, when you first open the login screen, it is added to the backstack. You enter text into the EditText field and then navigate to the register screen, which is also added to the backstack, overlaying the login screen. When you navigate to the register screen, the login screen remains in the backstack, indicating that it was not cleared or closed. So, when you try to call popBackStack(), it will close the current register screen and show the login screen that was still in the backstack. Fragment Backstack works in LIFO(Last in First Out) method. So if you want that text in EditText should be cleared, then you have to doit manunally, in onResume method or something like that.