Skip to content

Fix bottom sheet peek-to-expanded jump on show#6648

Open
loganrosen wants to merge 1 commit intohome-assistant:mainfrom
loganrosen:fix/bottom-sheet-animation
Open

Fix bottom sheet peek-to-expanded jump on show#6648
loganrosen wants to merge 1 commit intohome-assistant:mainfrom
loganrosen:fix/bottom-sheet-animation

Conversation

@loganrosen
Copy link
Copy Markdown
Contributor

Summary

When opening a bottom sheet (e.g. the server chooser via 3-finger swipe up), the sheet visibly jumps from peek height to expanded. This is because setLayoutAndExpandedByDefault() configures STATE_EXPANDED in an onShowListener, which fires after the sheet has already started its show animation at peek height.

This changes the approach to configure the BottomSheetBehavior directly in onViewCreated (before onStart shows the dialog), so the sheet starts directly in the expanded state without an intermediate peek. Also adds skipCollapsed so dismissal goes straight to hidden instead of stopping at collapsed.

Affects all callers: ServerChooserFragment, ImprovSetupDialog, and ImprovPermissionDialog.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Any other notes

No tests added — the fix is about when behavior properties are configured (before vs after dialog show), which is a timing concern that can't be meaningfully validated in a unit test. Tested manually on device.

Note: to test this on a debug build, I had to temporarily set WIPFeature.USE_FRONTEND_V2 = false because the new Compose frontend (FrontendScreen/HAWebView) doesn't have gesture detection yet — the swipe listener is only set up in the legacy WebViewActivity path.

Configure BottomSheetBehavior before the dialog is shown instead of in
an onShowListener. The previous approach set STATE_EXPANDED after the
sheet had already started its show animation at peek height, causing a
visible two-step animation (peek then jump to expanded).

Now the behavior is configured directly in onViewCreated (before
onStart shows the dialog), so the sheet starts directly in the expanded
state. Also adds skipCollapsed so dismissal goes straight to hidden.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 29, 2026 01:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the shared BottomSheetDialogFragment configuration helper so modal bottom sheets start expanded immediately (avoiding a visible peek-to-expanded jump) and dismiss directly to hidden by skipping the collapsed state.

Changes:

  • Configure BottomSheetDialog.behavior (expanded + skipCollapsed) directly instead of via an OnShowListener
  • Keep existing window defaults (dim amount + soft input resize) while applying them earlier

@TimoPtr
Copy link
Copy Markdown
Member

TimoPtr commented Mar 30, 2026

@loganrosen do you mind adding 2 videos in the PR description showing what is changing?

@jpelgrom
Copy link
Copy Markdown
Member

@loganrosen do you mind adding 2 videos in the PR description showing what is changing?

You just beat me to it. I spent the last 15 minutes fiddling with the animation scale and while the change sounds logical, I'm not seeing any difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants