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 false is not propagated to child controls #19139

Open
omghb opened this issue Nov 30, 2023 · 16 comments · Fixed by #20160 · May be fixed by #20154
Open

IsVisible false is not propagated to child controls #19139

omghb opened this issue Nov 30, 2023 · 16 comments · Fixed by #20160 · May be fixed by #20154
Labels
area-keyboard Keyboard, soft keyboard area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-8.0.10 fixed-in-9.0.0-preview.2.10293 platform/iOS 🍎 t/a11y Relates to accessibility t/bug Something isn't working
Milestone

Comments

@omghb
Copy link

omghb commented Nov 30, 2023

Description

If IsVisible="False" is set on a Grid then the child controls still return true for IsVisible.

On iOS this creates a bug as the keyboard "Next" button focus the invisible Entry an let the user type text into it.

Steps to Reproduce

  1. Create a new MAUI 8 app
  2. Open MainPage.xaml.cs and replace the content with:
namespace MauiApp1
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void HiddenEntry2Focused(object sender, FocusEventArgs e)
        {
            Console.WriteLine("Hidden entry: IsVisible: " + hiddenEntry2.IsVisible);
        }

        private void Entry3Focused(object sender, FocusEventArgs e)
        {
            Console.WriteLine("Hidden entry: IsVisible: " + hiddenEntry2.IsVisible);
        }
    }
}
  1. Open MainPage.xaml and replace the content with
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.MainPage">
    <ScrollView>
        <VerticalStackLayout Padding="30,0" Spacing="25">
            <Entry Placeholder="entry1" ReturnType="Next"/>

            <Grid IsVisible="False">
                <Entry x:Name="hiddenEntry2" Placeholder="hiddenEntry2" ReturnType="Next" Focused="HiddenEntry2Focused"/>
            </Grid>

            <Entry Placeholder="entry3" ReturnType="Next" Focused="Entry3Focused"/>
        </VerticalStackLayout>
    </ScrollView>
</ContentPage>
  1. Run the App on iOS
  2. Tap into the first entry and tap on the next button.

Result: Keyboard is shown for the hidden entry.

Maui8IosVisibilityIssue

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@omghb omghb added the t/bug Something isn't working label Nov 30, 2023
@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/iOS 🍎 labels Nov 30, 2023
@mattleibow
Copy link
Member

I tried this and was not able to reproduce this. Archive.zip

@mattleibow
Copy link
Member

mattleibow commented Nov 30, 2023

Ah, it happens on iOS when using the keyboard "next" button 😱 Seems to work with Tab on Android and Mac.

@mattleibow
Copy link
Member

@tj-devel709 thoughts?

@mattleibow mattleibow added this to the Backlog milestone Nov 30, 2023
@ghost
Copy link

ghost commented Nov 30, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@mattleibow mattleibow added legacy-area-a11y Relates to accessibility area-keyboard Keyboard, soft keyboard labels Nov 30, 2023
@omghb
Copy link
Author

omghb commented Dec 1, 2023

@mattleibow The keyboard "next" button is working on Android as expected but the code line

Console.WriteLine("Hidden entry: IsVisible: " + hiddenEntry2.IsVisible);

returns true on Android as well. This should be false as the parent Grid has set IsVisible="False".

@cucumber-sp
Copy link

@omghb no, it shouldn't be false. IsVisible on parent stops its rendering and rendering of children, but it doesn't change their properties.

@omghb
Copy link
Author

omghb commented Dec 5, 2023

@omghb no, it shouldn't be false. IsVisible on parent stops its rendering and rendering of children, but it doesn't change their properties.

@cucumber-sp That's not what I would expect. How would I find out (via code) that a Element is not visible (not rendered)?

@cucumber-sp
Copy link

@omghb not sure if there's a built-in solution for this, but I guess you can just go up untile parent is null, if some control has IsVisible set to false return false otherwise true. Make it and extension function and that's it

@tj-devel709
Copy link
Member

Yeah this behavior for the next button seems incorrect, I will take a look at this, thanks!

@bradencohen
Copy link
Contributor

@omghb not sure if there's a built-in solution for this, but I guess you can just go up untile parent is null, if some control has IsVisible set to false return false otherwise true. Make it and extension function and that's it

@omghb I'm curious what the Visibility property would return.

For ex: var visibility = ( (IView) Content ).Visibility

https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.iview.visibility?view=net-maui-8.0#microsoft-maui-iview-visibility

@omghb
Copy link
Author

omghb commented Dec 22, 2023

@bradencohen The Visibility property returns the same value as IsVisible. The element is hidden and should be Collapsed.

image

kubaflo added a commit to kubaflo/maui that referenced this issue Jan 25, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Jan 25, 2024
@kubaflo kubaflo linked a pull request Jan 25, 2024 that will close this issue
@kubaflo
Copy link
Contributor

kubaflo commented Jan 25, 2024

@Redth Redth moved this from Todo to In Progress in MAUI SDK Ongoing Jan 25, 2024
@Redth Redth modified the milestones: Backlog, .NET 8 SR3 Jan 25, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Feb 1, 2024
@mattleibow mattleibow reopened this Feb 5, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR3, .NET 8 SR4 Mar 5, 2024
@omghb
Copy link
Author

omghb commented Mar 15, 2024

Thanks for the improvement in MAUI 8.0.10:

Unfortunately, this fixes the issue only partly. Still not working:

  • Hide an element that has the focus
    • Expected: next focusable element gets the focus
    • Actual: focus stays on the hidden element
  • IsVisible property is not propagated to child controls

@PureWeen PureWeen moved this from In Progress to To Move in MAUI SDK Ongoing Mar 27, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR4, .NET 8 SR5 Apr 9, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR5, .NET 8 SR6 Apr 25, 2024
@Eilon Eilon added t/a11y Relates to accessibility and removed legacy-area-a11y Relates to accessibility labels May 10, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR6, .NET 8 SR7 Jun 3, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Jun 13, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Jun 13, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR7, Backlog Jun 15, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Sep 1, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Sep 1, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Sep 1, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Sep 1, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Sep 15, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-keyboard Keyboard, soft keyboard area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-8.0.10 fixed-in-9.0.0-preview.2.10293 platform/iOS 🍎 t/a11y Relates to accessibility t/bug Something isn't working
Projects
Status: No status