Skip to content

fix(android): stop dialog flashing when changing download options#138

Merged
linroid merged 4 commits into
mainfrom
fix/dialog-keyboard-flash
May 20, 2026
Merged

fix(android): stop dialog flashing when changing download options#138
linroid merged 4 commits into
mainfrom
fix/dialog-keyboard-flash

Conversation

@linroid
Copy link
Copy Markdown
Owner

@linroid linroid commented May 20, 2026

Fixes #135

Summary

Clicking the Speed / Priority / Schedule icons at the bottom of the Add Download dialog on Android caused the UI to flash repeatedly. Reported on S24 Ultra (Android 16, OneUI 8.5) in #135.

Root cause

The flash is the AlertDialog re-centering itself: every frame of the AnimatedContent size lerp changes the dialog's content height, and the dialog window has to recalculate its position above the IME, producing multiple visible jumps.

The earlier LocalFocusManager.clearFocus() attempt did not help because (a) clearFocus() doesn't actually dismiss the soft keyboard on Android (you need LocalSoftwareKeyboardController.hide() for that — confirmed during testing the keyboard stayed up), and (b) the underlying problem is the centered-dialog positioning, not the keyboard itself.

Fix

Switch to a bottom-anchored surface on mobile. A new AdaptiveModal composable picks ModalBottomSheet on Android/iOS and keeps AlertDialog on Desktop/Web. Bottom sheets grow upward when content resizes, so there is no position recalc and no jumps.

Also: PrioritySelector and ScheduleSelector now use FlowRow so chips wrap to the next line on narrow widths instead of overflowing.

Changes

  • expect val isMobilePlatform: Boolean — Android/iOS = true, JVM/Wasm = false.
  • AdaptiveModal — wraps ModalBottomSheet (mobile) or AlertDialog (desktop/web) behind a single API so feature code doesn't need to branch on platform.
  • AddDownloadDialog — now calls AdaptiveModal; dropped the LocalFocusManager / LocalSoftwareKeyboardController plumbing now that the modal surface is bottom-anchored.
  • PrioritySelector, ScheduleSelectorFlowRow instead of Row.

Test plan

  • Android: open Add download — sheet slides up from the bottom.
  • Type a URL so the keyboard stays up.
  • Tap Speed / Priority / Schedule — sheet smoothly grows upward, no flashing.
  • Toggle between the three icons — no flashing.
  • iOS: same as Android (ModalBottomSheet).
  • Desktop / Web: confirm Add download still appears as a centered AlertDialog and behaves normally.

Clicking the Speed/Priority/Schedule icons triggered repeated UI flashing
on Android. The URL field auto-focuses on dialog open, keeping the soft
keyboard up. Tapping an icon expands a new panel and grows the dialog;
the IME inset adjustment briefly resizes the dialog, but the URL field
still holds focus so the keyboard re-shows, which adjusts the inset
again - an IME/dialog feedback loop visible as flashing.

Clear focus via LocalFocusManager.clearFocus() at the top of each icon's
onClick handler so the keyboard dismisses cleanly before the panel
animation starts.
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

1 043 tests  ±0   1 043 ✅ ±0   14s ⏱️ -1s
   94 suites ±0       0 💤 ±0 
   94 files   ±0       0 ❌ ±0 

Results for commit 3f93eb7. ± Comparison against base commit f6e19f4.

linroid added 3 commits May 20, 2026 16:47
The earlier clear-focus attempt didn't address #135. clearFocus() does
not actually dismiss the soft keyboard on Android, and the real flash
was AlertDialog re-centering itself: every frame of the AnimatedContent
size lerp changed the dialog's content height, so the dialog window
recalculated its position above the IME, producing multiple visible
jumps.

Switch to a bottom-anchored surface on mobile. A new AdaptiveModal
composable picks ModalBottomSheet on Android/iOS and keeps AlertDialog
on Desktop/Web. Bottom sheets grow upward when content resizes, so
there is no position recalc and no jumps.

- Add expect val isMobilePlatform (Android/iOS = true, JVM/Wasm = false)
- Add AdaptiveModal wrapping ModalBottomSheet or AlertDialog
- Refactor AddDownloadDialog to use AdaptiveModal; drop the focus/
  keyboard plumbing now that the sheet handles layout interplay
Match the existing SpeedLimitSelector pattern so chips wrap to the
next line on narrow widths instead of overflowing.
@linroid linroid changed the title fix(android): stop UI flashing in AddDownloadDialog bottom icons fix(android): use ModalBottomSheet on mobile to stop dialog flashing May 20, 2026
@linroid linroid changed the title fix(android): use ModalBottomSheet on mobile to stop dialog flashing fix(android): stop dialog flashing when changing download options May 20, 2026
@linroid linroid merged commit 729b118 into main May 20, 2026
4 checks passed
@linroid linroid deleted the fix/dialog-keyboard-flash branch May 20, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialog flashes repeatedly when changing download options

1 participant