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

Dismiss is not working when tap outside of popup window #66

Closed
cvezina opened this issue Sep 15, 2019 · 6 comments
Closed

Dismiss is not working when tap outside of popup window #66

cvezina opened this issue Sep 15, 2019 · 6 comments
Assignees
Labels

Comments

@cvezina
Copy link

cvezina commented Sep 15, 2019

The popup window is not dismissed when you tap outside. You can reproduce the problem using the sample provided.

minSdkVersion 21
targetSdkVersion 28

@DeweyReed
Copy link

I encounter the same problem when I test the app on a Lollipop emulator. Removing this line can help although it's not a good solution: https://github.com/zawadz88/MaterialPopupMenu/blob/master/material-popup-menu/src/main/java/androidx/appcompat/widget/MaterialRecyclerViewPopupWindow.kt#L239

@zawadz88 zawadz88 self-assigned this Dec 6, 2019
@zawadz88 zawadz88 added the bug label Dec 6, 2019
@zawadz88
Copy link
Owner

zawadz88 commented Dec 6, 2019

@cvezina @DeweyReed thanks for reporting this.
I can reproduce this on Lollipop 5.0 emulator as well. I seems to be working on newer OS version so I'll need to investigate further.

@zawadz88
Copy link
Owner

zawadz88 commented Dec 6, 2019

It seems to be an issue on Lollipop only (5.0 and 5.1) - I've checked also API 19, 23, 25 & 28 and it's correct there on the emulator at least.

@zawadz88
Copy link
Owner

zawadz88 commented Dec 6, 2019

This seems to be an issue with clipping rounded backgrounds #47 .
I can see 2 solutions at the moment:

  1. Use clipToOutline on Marshmallow+ only i.e. change:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            dropDownList.clipToOutline = true
            // Move the background from popup to RecyclerView for clipToOutline to take effect.
            dropDownList.background = background
            popup.setBackgroundDrawable(null)
        }

to:

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            dropDownList.clipToOutline = true
            // Move the background from popup to RecyclerView for clipToOutline to take effect.
            dropDownList.background = background
            popup.setBackgroundDrawable(null)
        }
  1. Set popup.setBackgroundDrawable(null) on Marshmallow only i.e.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            dropDownList.clipToOutline = true
            // Move the background from popup to RecyclerView for clipToOutline to take effect.
            dropDownList.background = background
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                popup.setBackgroundDrawable(null)
            }
        }
  1. Means rounded corners will work only on M+ while 2. means we'll add overdraw on Lollipop devices.
    Before:
    Screenshot_1575648176
    After:
    Screenshot_1575648288

@Tunous do you have any thoughts on that?

@Tunous
Copy link
Contributor

Tunous commented Dec 6, 2019

Option 2 appears to be a better solution in this case. I’m not sure whether removing it is entirely safe but I also don’t remember if there were any other issues which this line was intended to resolve. Most likely these were on other Android version (if ever).

@zawadz88 zawadz88 mentioned this issue Dec 8, 2019
@zawadz88
Copy link
Owner

zawadz88 commented Dec 8, 2019

Fixed in 4.0.1.
Thanks all for contributing!

@zawadz88 zawadz88 closed this as completed Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants