ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.78k stars 2.25k forks source link

[BUG]: First Click on Graph Scrolls Page to Top #17276

Open brishtibheja opened 1 month ago

brishtibheja commented 1 month ago

Checked for duplicates?

Does it also happen in the desktop version?

What are the steps to reproduce this bug?

  1. Go to Statistics.
  2. Go to the bottom at Added graph.
  3. Click on a bar on the right side of the graph.

Expected behaviour

The page scrolls to just above the graph. The next click works completely fine.

Debug info

2.19beta6

(Optional) Anything else you want to share?

This issue existed back when the new statistics was added. It was reported here: https://github.com/ankidroid/Anki-Android/issues/15805

The fix was working fine until recently. On another device, I can't reproduce this using beta5 so it's probably beta6 that introduced this.

Research

deysak commented 1 month ago

The bug resurfaced after https://github.com/ankidroid/Anki-Android/pull/17250 (which used a custom WebView implementation to handle nested scroll for Statistics), and was gone after https://github.com/ankidroid/Anki-Android/pull/16027 (which used NestedScrollView to handle nested scroll for Statistics), before which the same bug existed.

The custom WebView implementation does not appears to be the root cause of the bug, as using the vanilla WebView also results in the same bug.

Somehow NestedScrollView unintentionally suppressed the cause,

likely because how it treats the incoming WebView:

![Image](https://github.com/user-attachments/assets/0b27b049-2263-47b0-8494-2a5ccfd811da)

Which is in contrast to native/custom WebView:

![Image](https://github.com/user-attachments/assets/5c800369-7d0c-4883-b0f6-f35a294ae855)