Skip to content

[DON-4207] Add dimBackground option to BpkModal - #2908

Merged
peterliu (peterInTown) merged 2 commits into
mainfrom
DON-4207-bpk-modal-dim-background
Nov 26, 2026
Merged

peterliu (peterInTown) merged 2 commits into
mainfrom
DON-4207-bpk-modal-dim-background

Conversation

@peterInTown

@peterInTown peterliu (peterInTown) commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a dimBackground: Boolean = true parameter to BpkModal, and makes animated = false also disable the dialog window's own enter/exit animation.

BpkModal is shown in a Dialog window. That window dims the content behind it and plays its own default window animation. animated = false (#2895) only removed the slide, so when a modal that covers the whole screen is shown with animated = false, the dim still fades in and out behind it. On dismiss this shows up as a grey frame after the modal has already disappeared.

When dimBackground = false, FLAG_DIM_BEHIND is cleared on the dialog window. When animated = false, the window animations are set to 0. The defaults are unchanged, so existing consumers are not affected.

Why

In Skyscanner's app the Search Control GC (BpkModal) opens on a screen that is itself pushed with a slide transition and uses animated = false. The leftover dim and window animation are visible as a flash on open and as a grey frame on close.

Changes

  • BpkModal / BpkModalImpl: new dimBackground parameter, and window animations disabled when animated = false
  • docs/compose/Modal/README.md: documented under "Dimmed background"
  • BpkModalAnimatedTest (androidTest): the window dims behind by default, does not dim with dimBackground = false, and has no window animations when animated = false

Testing

  • detekt passes
  • BpkModalAnimatedTest passes on API 35 and API 37 emulators (5/5)
  • No visual change to existing modals, so no snapshot updates

Remember to include the following changes:

  • Component README.md
  • Tests

…imations when not animated #trivial

The modal is shown in a Dialog window that dims the content behind it and plays its own enter/exit animation. When the modal is not animated and covers the screen, the dim only shows as a flash while it appears or disappears.

Co-authored-by: OpenCode <noreply@opencode.ai>
Copilot AI lite review requested due to automatic review settings November 26, 2026 16:31
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor
Warnings
⚠️ One or more component files were updated, but the tests weren't updated. If your change is not covered by existing tests please add snapshot tests.
⚠️

One or more component files were updated, but the docs screenshots weren't updated. If the changes are visual or it is a new component please regenerate the screenshots via ./gradlew recordScreenshots.

Generated by 🚫 Danger Kotlin against df04065

@peterInTown peterliu (peterInTown) added the minor A new & backwards compatible feature/component label Nov 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Adds configurability to BpkModal’s dialog window behavior by introducing a dimBackground option and ensuring animated = false fully disables dialog/window animations to avoid visible flashes.

Changes:

  • Add dimBackground: Boolean = true parameter to BpkModal / BpkModalImpl.
  • Clear FLAG_DIM_BEHIND when dimBackground = false and disable window animations when animated = false.
  • Document the new option and extend androidTests to validate dimming and window animation behavior.
File Description
docs/​compose/​Modal/​README.md Documents the new dimBackground option and when to use it
backpack-compose/​src/​main/​kotlin/​net/​skyscanner/​backpack/​compose/​modal/​internal/​BpkModalImpl.kt Applies dialog window flag/animation changes based on new parameters
backpack-compose/​src/​main/​kotlin/​net/​skyscanner/​backpack/​compose/​modal/​BpkModal.kt Exposes dimBackground in the public API and updates KDoc
backpack-compose/​src/​androidTest/​kotlin/​net/​skyscanner/​backpack/​compose/​modal/​BpkModalAnimatedTest.kt Adds coverage for dim-behind default/override and window animations disabled when animated = false

Review effort: Lite

Comment thread docs/compose/Modal/README.md Resolved
@RichSutherSky
RichSutherSky self-requested a review November 26, 2026 17:07
…ange back #trivial

- Apply both branches of dimBackground and restore the dialog's default window animations when animated becomes true again
- Read the dialog window inside runOnIdle in the tests and cover the restore cases

Co-authored-by: OpenCode <noreply@opencode.ai>
Copilot AI lite review requested due to automatic review settings November 26, 2026 17:24
@peterInTown
peterliu (peterInTown) merged commit 2ff4436 into main Nov 26, 2026
19 of 20 checks passed
@peterInTown
peterliu (peterInTown) deleted the DON-4207-bpk-modal-dim-background branch November 26, 2026 17:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
3 resolved since last review

Review effort: Lite

Comment on lines +129 to +137
private fun <T> readDialogWindow(read: Window.() -> T): T {
var result: T? = null
composeTestRule.runOnIdle {
val window = checkNotNull(dialogWindow) { "The modal's dialog window was not composed" }
result = window.read()
}
@Suppress("UNCHECKED_CAST")
return result as T
}
The modal is shown in its own window, which dims the content behind it. When the modal covers the whole screen the dim is
only visible as a flash while the modal appears or disappears, for example when `animated = false`. Set
`dimBackground = false` to turn it off.

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

Labels

minor A new & backwards compatible feature/component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants