Skip to content

fix: prevent deck overlap by skipping redundant scroll for visible items#20406

Open
Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Ayush-Patel-56:fix-deck-picker-overlap
Open

fix: prevent deck overlap by skipping redundant scroll for visible items#20406
Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Ayush-Patel-56:fix-deck-picker-overlap

Conversation

@Ayush-Patel-56
Copy link
Contributor

@Ayush-Patel-56 Ayush-Patel-56 commented Mar 6, 2026

Purpose / Description

Fixes visual overlapping of deck names/counts when a deck is tapped.

Fixes

Approach

Skips the programmatic centering scroll if the deck is already visible to the user. This avoids a layout conflict between the scroll and the adapter's repaint.

How Has This Been Tested?

Verified on Android 11 (API 30) emulator. Taps on visible decks are now smooth without glitches, and secondary focus (returning from reviewer) still centers correctly.

555479092-e320972d-6637-417e-9dcd-c93c9d616f72.mp4

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@david-allison
Copy link
Member

What's the debug info of the emulator you used to test?

Tapping an empty deck should show the congrats screen successfully

@Ayush-Patel-56
Copy link
Contributor Author

Debug Info:

AnkiDroid Version = 2.24.0alpha7-debug (3d021cd09255a320a9d02fc8051d10456d1c783a)  
Backend Version = 0.1.63-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)  
Android Version = 11 (SDK 30)  
ProductFlavor = play  
Device Info = Google | google | generic_x86_arm | sdk_gphone_x86 | sdk_gphone_x86 | ranchu  
WebView Info = [com.google.android.webview | 410410681]: Mozilla/5.0 (Linux; Android 11; sdk_gphone_x86 Build/RSR1.240422.006; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36  
ACRA UUID = 79647706-b83f-40d9-8d1a-6f2068b16230  
FSRS = 5.1.0 (Enabled: false)  
Crash Reports Enabled = false

Congrats Screen: I have verified the Congrats Screen on both a emulator (API 30) and a modern device.

  • The white screen was a pre-existing issue on the emulator (API 30) (it happened on main too).
  • On a modern device, the "Congratulations! You have finished this deck for now" message appears perfectly.


fun onFocusedDeckChanged(deckId: DeckId?) {
val position = deckId?.let { viewModel.findDeckPosition(it) } ?: 0
val firstVisible = decksLayoutManager.findFirstVisibleItemPosition()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain why this occurs to a reader.

  • Add a comment,
  • Optionally add a LinearLayoutManager.positionIsVisible(position: Int) method so the intent of the code is obvious
if (decksLayoutManager.positionIsVisible(position)) {
    return
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the positionIsVisible helper to LinearLayoutManager.kt as suggested. Also put in a short comment explaining the issue.

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent diagnostics!

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 6, 2026
@Ayush-Patel-56 Ayush-Patel-56 force-pushed the fix-deck-picker-overlap branch from 3d021cd to c101225 Compare March 6, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Deck picker screen, decks visually overlap just after being tapped

2 participants