Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

[BUG] Search leaves app in inconsistent state #1587

Open
Garfield96 opened this issue Jun 11, 2023 · 2 comments
Open

[BUG] Search leaves app in inconsistent state #1587

Garfield96 opened this issue Jun 11, 2023 · 2 comments
Labels

Comments

@Garfield96
Copy link

Describe the bug
Using the search can leave the app in an inconsistent state. If the search gets canceled, using the back button (top left), the keyboard is shown on the "Home" page. Entered text is not visible, but the error messages from the search are shown. E.g. if I enter less than three characters, the corresponding error is shown on the "Home" page (see screenshot 1). The menu is also affected by this mixed state and shows incorrect padding (see screenshot 2).

To Reproduce
Steps to reproduce the behavior:

  1. Go back and forth between the search and other pages several times.
  2. Switch to the search again and use the back button (top left).
  3. See the keyboard on "Home" page. If the keyboard is not shown, go back to step 1.
  4. Open the menu to see the incorrect padding.

Expected behavior
The keyboard is not shown on the "Home" page, and there should be no change to the menu.

Screenshots



Smartphone :

  • Phone: Redmi Note 8 Pro
  • OS version: 11 RP1A.200720.011
  • Language: German

Additional context
I also occasionally experienced random app crashes in this state, which could be related to #1517.

@SecretIdetity
Copy link

reproducible on poco x4 pro 5g, MIUI 13.0.5, Android 12 SKQ1.211006.001, App latest 4.1

@zaghdaneh
Copy link
Contributor

I tried to find the reason behind the problem and after a lot of logging this is what I found out :

Most of the time when clicking on the back button in the SearchFragment, the MainFragment (for the first screen of the app) is created. But Sometimes, for a reason I'm still unsure of, it creates a new Search fragment and then creates a new Main fragment (in quick succession, so quick that you don't see it happen) which explains why the keyboard problem appears.

The problem isn't that the keyboard doesn't disappear, it's that the OnViewCreated of the SearchFragment calls the ShowKeyboard() function (which is supposed to hide when user presses on back but it doesn't happen in this case).
The drawer having a big top padding appear is directly related to the keyboard being on screen (you can try this out by removing the hideKeyboard() call in the SearchFragment backIcon behaviour

Bandaid fix

I can put out a pull request but I think the fix I found is more of a bandaid fix as I didn't find the real reason this edge case happens. When this situation happens the onViewCreated function of the SearchFragment is called but not the OnCreate() function. Using a boolean that is initialized to false that is set to true when onViewCreated finishes executing blocks any further unwanted behaviour and seems to cause the problem to not happen anymore from the tests I run.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants