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

Stuck after changing UIMode light/dark #127

Closed
myounis97 opened this issue May 22, 2024 · 4 comments · Fixed by #130
Closed

Stuck after changing UIMode light/dark #127

myounis97 opened this issue May 22, 2024 · 4 comments · Fixed by #130
Assignees
Labels
bug Something isn't working

Comments

@myounis97
Copy link

myounis97 commented May 22, 2024

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:

  1. Make sure the overlay is presented
  2. Switch the UIMode from the notifications drawer
  3. Click on the overlay
  4. 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
			}
		}
@myounis97 myounis97 added the bug Something isn't working label May 22, 2024
@svenjacobs
Copy link
Owner

Hello @myounis97, thanks for the bug report. I can confirm this behavior. I will have a look into it 👀

@svenjacobs
Copy link
Owner

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.

svenjacobs added a commit that referenced this issue May 24, 2024
* chore: add example app for easier debugging

* fix: click modifier not working after config change (issue #127)
@svenjacobs
Copy link
Owner

@myounis97 By the way, what a funny coincidence that your library has a similar name 😁

@myounis97
Copy link
Author

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.

Thanks for your efforts 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants