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

IsVisible binding not showing items again if Shadow is set #15357

Closed
dan-matthews opened this issue May 31, 2023 · 4 comments · Fixed by #16941
Closed

IsVisible binding not showing items again if Shadow is set #15357

dan-matthews opened this issue May 31, 2023 · 4 comments · Fixed by #16941
Assignees
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@dan-matthews
Copy link

dan-matthews commented May 31, 2023

Description

A very, very strange bug! It always works correctly on Windows, but on Android there is a bug. In my app, the IsVisible for a button is set using binding (MVVM). Setting IsVisible false will always hide the button, but setting IsVisible true is NOT showing the button. However, I found that a styling for the Button was causing the issue. Specifically, the setter (in a Styles.xaml file) was as follows:

    <Setter Property="Shadow">
        <Shadow Brush="Black"
            Offset="4,4"
            Opacity="0.9" />
    </Setter>

When the setter is swapped for individual setters, the IsVisible works:

    <Setter Property="Shadow.Offset" Value="4,4"/>
    <Setter Property="Shadow.Opacity" Value="0.9"/>
    <Setter Property="Shadow.Brush" Value="Black"/>

For some reason, the 'nested' style setter for Shadow seems to be affecting the visibility toggle of the element, but only on Android.

Steps to Reproduce

  1. Create a starter Maui app (XAML)
  2. Add the following to the Button style in Styles.xaml

<Setter Property="Shadow"> <Shadow Brush="Black" Offset="4,4" Opacity="0.9" /> </Setter>

  1. Add a button to the MainPage with IsVisible to a bound property initialized false
  2. Toggle the bound property to true (e.g. via another button)

Expected: Button becomes visible
Actual: Button stays hidden

Link to public reproduction project repository

(https://github.com/dan-matthews/VisibleTest)

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11+

Did you find any workaround?

Use individual style setters for Shadow.

Relevant log output

No response

@dan-matthews dan-matthews added the t/bug Something isn't working label May 31, 2023
@jsuarezruiz jsuarezruiz added platform/android 🤖 area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing labels Jun 1, 2023
@jsuarezruiz jsuarezruiz self-assigned this Jun 1, 2023
@jsuarezruiz jsuarezruiz added the s/needs-repro Attach a solution or code which reproduces the issue label Jun 1, 2023
@ghost
Copy link

ghost commented Jun 1, 2023

Hi @dan-matthews. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jsuarezruiz
Copy link
Contributor

Cannot reproduce the issue on current main branch:
issue-15357

@dan-matthews
Copy link
Author

Added a link to a repo.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Jun 5, 2023
@PureWeen PureWeen assigned mauroa and unassigned jsuarezruiz Aug 21, 2023
@mauroa mauroa moved this to In Progress in MAUI SDK Ongoing Aug 22, 2023
mauroa added a commit that referenced this issue Aug 22, 2023
Visibility and Opacity settings were not working correctly when the control was inside a container.
For the case of visibility, it was only being set for the container when it needed to be set for both the container and the control.
For the case of opacity, it was also only being set for the container, which could reduce the opacity of the control as a side effect because it's a value affected by its parent value. In this case, we need to ensure the control has 100% opacity so it applies and uses the correct value to the container.

Fixes:
#15826
#15357
PureWeen pushed a commit that referenced this issue Aug 25, 2023
* [android] Fixed ListView visibility and opacity on Android

Visibility and Opacity settings were not working correctly when the control was inside a container.
For the case of visibility, it was only being set for the container when it needed to be set for both the container and the control.
For the case of opacity, it was also only being set for the container, which could reduce the opacity of the control as a side effect because it's a value affected by its parent value. In this case, we need to ensure the control has 100% opacity so it applies and uses the correct value to the container.

Fixes:
#15826
#15357

* Added Appium tests for Visibility issues #15826 and #15357

* Added Appium tests for Opacity issues #12211

* Applied PR feedback: Remove added items from Controls.Sample.UITests.csproj
@mauroa mauroa closed this as completed Aug 25, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Aug 25, 2023
@PureWeen
Copy link
Member

Duplicate of #15826

@PureWeen PureWeen marked this as a duplicate of #15826 Aug 25, 2023
@samhouts samhouts added the fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 label Sep 12, 2023
@samhouts samhouts added this to the .NET 8 + Servicing milestone Sep 19, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants