Skip to content

fix(Android): always release modal lifecycle listener - #8357

Open
OskarEichler wants to merge 1 commit into
wix:masterfrom
OskarEichler:codex/cleanup-modal-host-lifecycle
Open

fix(Android): always release modal lifecycle listener#8357
OskarEichler wants to merge 1 commit into
wix:masterfrom
OskarEichler:codex/cleanup-modal-host-lifecycle

Conversation

@OskarEichler

Copy link
Copy Markdown

Problem and fix

ModalHostLayout registers itself as a React lifecycle listener during construction. ModalViewManager.onDropViewInstance removed that listener only inside navigator?.let, so dropping a modal while there was no active NavigationActivity/navigator left the discarded host registered with ReactContext.

This can occur while an activity is absent, finishing, or destroyed. The stale lifecycle registration retains unnecessary work and references after the React view has been dropped.

The cleanup now runs in finally, preserving dismissal when a navigator exists while guaranteeing onDropInstance() when it does not—or if synchronous dismissal fails.

Regression coverage

The new Robolectric test drops a modal with no active activity/navigator and verifies that its lifecycle listener is still removed. The exact baseline fails this assertion.

Verification

  • focused regression: 1/1 passed
  • full Android unit suite: 698 passed, 2 skipped, 0 failed
  • Android debug Kotlin/Java compilation passed
  • git diff --check passed

Breaking changes

None. This guarantees existing teardown behavior on every drop path.

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