reveal
reveal copied to clipboard
Stuck after changing UIMode light/dark
Describe the bug After switching from/to light/dark mode the overlay view becomes not clickable and the content under the overlay becomes clickable
To Reproduce Steps to reproduce the behavior:
- Make sure the overlay is presented
- Switch the UIMode from the notifications drawer
- Click on the overlay
- See error
Expected behavior The overlay should intercept click events not the content behind it
Smartphone (please complete the following information):
- All devices
Additional Context
This line becomes null after configuration change val rev by rememberUpdatedState(currentRevealable.value)
So the launched effect only takes the alpha as key and it would not update the clickModifier
val clickModifier = when {
revealState.isVisible && rev != null -> Modifier.pointerInput(Unit) {
detectTapGestures(
onPress = { offset ->
rev?.key?.let(
if (rev?.area?.contains(offset) == true) {
rev?.onClick ?: onRevealableClick
} else {
onOverlayClick
},
)
},
)
}
else -> Modifier
}
LaunchedEffect(animatedOverlayAlpha) {
@Suppress("ktlint:standard:wrapping")
revealCanvasState.overlayContent = when {
animatedOverlayAlpha > 0.0f -> ({
overlayEffect.Overlay(
revealState = revealState,
currentRevealable = currentRevealable,
previousRevealable = previousRevealable,
modifier = clickModifier
.semantics { testTag = "overlay" }
.fillMaxSize()
.alpha(animatedOverlayAlpha),
content = overlayContent,
)
})
else -> null
}
}
Hello @myounis97, thanks for the bug report. I can confirm this behavior. I will have a look into it 👀
This has been fixed in #130.
You're right that rev briefly becomes null. That is if a configuration change like dark mode is not explicitly handled by an application, the Activity will be restarted. Then RevealState is restored, since it is saveable, and rev points to the revealable item again.
However for some reason clickModifier wasn't properly updated and was still the empty Modifier from the else branch. By removing rev != null from the condition the modifier is properly updated.
The fix will be available in version 3.0.7.
@myounis97 By the way, what a funny coincidence that your library has a similar name 😁
This has been fixed in #130.
You're right that
revbriefly becomesnull. That is if a configuration change like dark mode is not explicitly handled by an application, theActivitywill be restarted. ThenRevealStateis restored, since it is saveable, andrevpoints to the revealable item again.However for some reason
clickModifierwasn't properly updated and was still the emptyModifierfrom theelsebranch. By removingrev != nullfrom the condition the modifier is properly updated.The fix will be available in version
3.0.7.
Thanks for your efforts 🚀