Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Android): crash on tab change with open form sheet #2416

Merged
merged 9 commits into from
Oct 21, 2024

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Oct 18, 2024

Description

This PR fixes android crash when changing tab with formSheet opened.

The fix is achieved by not triggering dismissSelf() in the ON_STOP lifecycle event, which was intended to run with native events, such as pulling the sheet down, but was also triggered by this particular case - causing the FragmentManager is already executing transactions ERROR.

To ensure the dismissal is correctly triggered by the native events, a NativeDismissalObserver was created and is triggered by BottomSheetBehavior.STATE_HIDDEN state change.

After applying the fix another problem appeared: upon re-visiting a tab with formSheet opened it's background turned transparent.

During the first attachShapeToScreen screens background property is replaced with shape of type MaterialShapeDrawable. Thus on each subsequent call the (screen.background as? ColorDrawable?)?.color property is unreachable as it's not ColorDrawable anymore. It's fixed by looking for (screen.background as? MaterialShapeDrawable?)?.tintList?.defaultColor fallback.

Fixes #2379 .

Changes

  • added nativeDismissalObserver
  • fixed sheet bg color not applying when re-visited.
  • added Test2379 repro

Test code and steps to reproduce

  • use Test2379 repro

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@alduzy alduzy force-pushed the @kkafar/formsheet-crash branch from d7af2d1 to 80fb2eb Compare October 18, 2024 11:56
@alduzy alduzy force-pushed the @kkafar/formsheet-crash branch from 80fb2eb to edb4b3e Compare October 18, 2024 12:01
@alduzy alduzy force-pushed the @kkafar/formsheet-crash branch from d746aed to f2641e6 Compare October 18, 2024 12:13
@kkafar kkafar merged commit 5ff656e into main Oct 21, 2024
3 of 4 checks passed
@kkafar kkafar deleted the @kkafar/formsheet-crash branch October 21, 2024 12:20
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.

Android crashes on changing tab with formSheet opened inside
2 participants