Skip to content

fix(compose-sdk): restore dialog dim after hidden loading#248

Open
e271828- wants to merge 1 commit intomainfrom
fix/alt_dimming
Open

fix(compose-sdk): restore dialog dim after hidden loading#248
e271828- wants to merge 1 commit intomainfrom
fix/alt_dimming

Conversation

@e271828-
Copy link
Contributor

Summary

This restores the Compose dialog dimming behavior for loading=false so it matches the existing View SDK semantics.

Intended behavior

  • If loading=false, the dialog should start without the dim-behind backdrop while the captcha is still hidden/loading.
  • If a visible checkbox is rendered, the dialog should regain its normal dimmed backdrop as soon as the checkbox is shown.
  • If an invisible flow escalates into a visible challenge, the dialog should regain its normal dimmed backdrop when that visible state is entered.
  • Existing behavior outside this transition should remain unchanged, including embedded rendering, dialog cancellation, and preloaded WebView reuse.

Implementation

  • Replace the window global-layout dim mutation with state-driven dim handling in Compose.
  • Restore dim on the same semantic transitions already used by the View SDK:
    • Loaded for checkbox sizes
    • Opened for invisible flows
  • Centralize the dialog window flag management in a helper that preserves the original window dim configuration and restores it on disposal.

Validation

Ran on the Medium_Phone emulator with normal Gradle instrumentation:

./gradlew :test:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.hcaptcha.sdk.compose.HCaptchaComposeTest

Passed: 11/11 tests, 0 failures.

That includes coverage for:

  • loading=false remaining undimmed while the captcha is still hidden
  • dim restoration when a checkbox becomes visible
  • dim restoration when the invisible-flow visible state is entered
  • existing Compose dialog flows such as cancellation, back handling, custom host rendering, and preloaded WebView reuse

Keep Compose dialog dimming aligned with the View SDK when loading is disabled.

Intended behavior:
- If loading=false, the dialog should start without the dim-behind backdrop while the captcha is still hidden/loading.
- If a visible checkbox is rendered, the dialog should regain its normal dimmed backdrop as soon as the checkbox is shown.
- If an invisible flow escalates into a visible challenge, the dialog should regain its normal dimmed backdrop when that visible state is entered.
- Unchanged flows such as embedded rendering, dialog cancellation, and preloaded WebView reuse should keep their prior behavior.

Implementation:
- Track dialog dimming as Compose state instead of repeatedly mutating the window from a global layout listener.
- Restore dim on the same semantic transitions used by the View SDK: Loaded for checkbox sizes, Opened for invisible flows.
- Centralize window flag updates in a dialog setup helper that preserves and restores the window's original dim configuration.

Tests:
- Add emulator-backed coverage for the loading=false hidden state.
- Add emulator-backed coverage for dim restoration when a checkbox becomes visible.
- Add emulator-backed coverage for the invisible-flow dim restoration state transition.
- Preserve existing Compose behavior checks for embedded mode, dialog cancellation, and WebView reuse.
@github-actions
Copy link

Diffuse report:

OLD: sdk-main.aar
NEW: sdk-pr.aar

 AAR      │ old       │ new       │ diff 
──────────┼───────────┼───────────┼──────
      jar │  65.6 KiB │  65.6 KiB │  0 B 
 manifest │     411 B │     411 B │  0 B 
      res │  78.2 KiB │  78.2 KiB │  0 B 
    other │     1 KiB │     1 KiB │  0 B 
──────────┼───────────┼───────────┼──────
    total │ 145.2 KiB │ 145.2 KiB │  0 B 

 JAR     │ old │ new │ diff      
─────────┼─────┼─────┼───────────
 classes │  40 │  40 │ 0 (+0 -0) 
 methods │ 603 │ 603 │ 0 (+0 -0) 
  fields │ 188 │ 188 │ 0 (+0 -0)

@github-actions
Copy link

Benchmark report:

Test name Time ms. (median) Allocations (median)
com.hcaptcha.sdk.HCaptchaBenchmarkTest.EMULATOR_UNLOCKED_benchmarkInvisibleVerification +481.39 +771
com.hcaptcha.sdk.HCaptchaBenchmarkTest.EMULATOR_UNLOCKED_benchmarkInvisibleVerificationColdRun +982.96 +1204
com.hcaptcha.sdk.HCaptchaBenchmarkTest.EMULATOR_UNLOCKED_benchmarkInvisibleSetup +6.08 +423
com.hcaptcha.sdk.HCaptchaDebugInfoTest.EMULATOR_UNLOCKED_benchmarkDebugInfo +40.07 -5590
com.hcaptcha.sdk.HCaptchaDebugInfoTest.EMULATOR_UNLOCKED_benchmarkDebugSys +53.47 +2

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.

1 participant