Skip to content

[Windows] Respect ClearButtonVisibility = ClearButtonVisibility.Never for <Entry>s#23158

Merged
mattleibow merged 6 commits into
dotnet:mainfrom
MartyIX:feature/2024-06-20-Hide-Entry-Clear-Button
Jul 10, 2024
Merged

[Windows] Respect ClearButtonVisibility = ClearButtonVisibility.Never for <Entry>s#23158
mattleibow merged 6 commits into
dotnet:mainfrom
MartyIX:feature/2024-06-20-Hide-Entry-Clear-Button

Conversation

@MartyIX

@MartyIX MartyIX commented Jun 20, 2024

Copy link
Copy Markdown
Contributor

Description of Change

The style interception code works sometimes but not always.

Relevant XAML template in WinUI 3 is here.

Issues Fixed

Fixes #23112
Related to #13714

PR that introduced the modified code: #3444

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Jun 20, 2024
}
else
{
deleteButton.RenderTransform = new UI.Xaml.Media.TranslateTransform() { Y = -1000 };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to take into account parent's height, I guess. Or perhaps parent window height. Or something.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you have entries in a scroll view... Will it be a floating button somewhere?

@MartyIX MartyIX Jun 28, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, one can modify src\Controls\samples\Controls.Sample.Sandbox\MainPage.xaml like this:

<ContentPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Maui.Controls.Sample.MainPage"
    xmlns:local="clr-namespace:Maui.Controls.Sample">
  <VerticalStackLayout Background="Lightgray">
    <ScrollView BackgroundColor="Gray" WidthRequest="300" HeightRequest="300" 
                HorizontalScrollBarVisibility="Always" VerticalScrollBarVisibility="Always">
      <Entry ClearButtonVisibility="Never" Text="Entry at your service" HeightRequest="30" Margin="0,1500,0,0" />
    </ScrollView>
  </VerticalStackLayout>
</ContentPage>

to test the issue. And yes, you are right that the button was visible there.

I modified it like this 627e084. I'm aware it's still a workaround but in practice, it should work well.

An additional step can be to set deleteButton.Opacity = 0. But I don't find it good as it costs some performance.

My conclusion is that this PR attempts to replace one workaround for another one (it is IMHO better). Hopefully, the WinUI team will provide a way to hide the button easily one day - that would be the best thing.

@MartyIX MartyIX marked this pull request as ready for review June 20, 2024 11:49
@MartyIX MartyIX requested a review from a team as a code owner June 20, 2024 11:49
else if (!isEnabled && contains)
states.Remove(buttonVisibleState);
return;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this is a workaround as well. So if the approach of this PR is ok, then it would be a replacement of a workaround for a workaround.

@MartyIX

MartyIX commented Jun 20, 2024

Copy link
Copy Markdown
Contributor Author

Could anyone run tests for this PR just to know if they pass or not?

@MartyIX

MartyIX commented Jun 27, 2024

Copy link
Copy Markdown
Contributor Author

@mattleibow What do you think please?

@mattleibow

Copy link
Copy Markdown
Member

/rebase

@github-actions github-actions Bot force-pushed the feature/2024-06-20-Hide-Entry-Clear-Button branch from f2eeab9 to 5193b28 Compare June 28, 2024 06:17
@mattleibow

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@MartyIX MartyIX force-pushed the feature/2024-06-20-Hide-Entry-Clear-Button branch from 83dc2c1 to 627e084 Compare June 28, 2024 11:48
@MartyIX

MartyIX commented Jul 2, 2024

Copy link
Copy Markdown
Contributor Author

@mattleibow Does it look better to you now?

@mattleibow

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow

mattleibow commented Jul 2, 2024

Copy link
Copy Markdown
Member

Are you able to add a UI test? I have a feeling this one is going to break randomly when we update wasdk.

@MartyIX MartyIX force-pushed the feature/2024-06-20-Hide-Entry-Clear-Button branch 2 times, most recently from 8cc9c2e to 5785a0a Compare July 2, 2024 12:05
@MartyIX

MartyIX commented Jul 2, 2024

Copy link
Copy Markdown
Contributor Author

Are you able to add a UI test?

I added 280f81c as the first commit so that one can easily check that the test fails without the new "workaround".

The test is partially done according to #23112 and its Steps to Reproduce.

I have a feeling this one is going to break randomly when we update wasdk.

Yes, I can imagine that.

@mattleibow

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow

Copy link
Copy Markdown
Member

Thanks for the test, now to bend CI to our will and ask it to do the basic job of running the tests properly.

@MartyIX

MartyIX commented Jul 3, 2024

Copy link
Copy Markdown
Contributor Author

So I can see that a screenshot must be added. Not sure if some other test genuinely failed.

@mattleibow

Copy link
Copy Markdown
Member

You can download the screenshots from the devops test attachments. Just go to the failed test and the attachments tab. Should be there. It is the one without the nav bars and status bars.

@mattleibow

Copy link
Copy Markdown
Member

I think the layout will not really work on mobile:

Android iOS
image image

https://dev.azure.com/xamarin/public/_build/results?buildId=118577&view=ms.vss-test-web.build-test-results-tab&runId=2906687&resultId=100119&paneView=attachments

But it seems to be right for Windows:

image

I wonder if it will work if you have jus a flay vertical stack layout?

@MartyIX MartyIX force-pushed the feature/2024-06-20-Hide-Entry-Clear-Button branch from 5785a0a to b16a52d Compare July 3, 2024 19:50
@MartyIX MartyIX force-pushed the feature/2024-06-20-Hide-Entry-Clear-Button branch 2 times, most recently from 0968321 to 4f014f0 Compare July 4, 2024 13:55
@MartyIX

MartyIX commented Jul 4, 2024

Copy link
Copy Markdown
Contributor Author

Added a Windows snapshot. No snapshot for macOS so far.


await Task.Delay(500);

VerifyScreenshot();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS won't generate screen shots so I would just ignore this test on macOS

Do we need the 500 ms delays?

VerifyScreenshot already does a delay and retry

@MartyIX MartyIX Jul 4, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that the delay before VerifyScreenshot() is necessary I just wanted to be sure.

The previous delay, I'm not sure. It's very hard for me to tell. I just find it safer with the delay. I guess you are concerned with the CI test time, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that I have a limited set of tries, I play it safe. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to change it in 67b3766.

Unfortunately, for some reason I'm seeing locally

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	NETSDK1047	Assets file 'D:\maui\artifacts\obj\Controls.TestCases.HostApp\project.assets.json' doesn't have a target for 'net8.0-ios/ios-arm64'. Ensure that restore has run and that you have included 'net8.0-ios' in the TargetFrameworks for your project. You may also need to include 'ios-arm64' in your project's RuntimeIdentifiers.	Controls.TestCases.HostApp (net8.0-ios)	C:\Program Files\dotnet\sdk\8.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets	266	

So I can't run the test locally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartyIX MartyIX force-pushed the feature/2024-06-20-Hide-Entry-Clear-Button branch from 4f014f0 to 67b3766 Compare July 6, 2024 08:37
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen requested review from Foda and removed request for jfversluis and tj-devel709 July 6, 2024 15:01
@mattleibow

Copy link
Copy Markdown
Member

Trying the tests on Windows Core unpackaged again... Probably not related since the packaged version ran. But just to be safe. Might just merge if it fails again and see if main fixes it.

@mattleibow

Copy link
Copy Markdown
Member

Well, now it is green so whatever CI.

@mattleibow mattleibow merged commit 79f4c50 into dotnet:main Jul 10, 2024
@MartyIX MartyIX deleted the feature/2024-06-20-Hide-Entry-Clear-Button branch July 10, 2024 06:27
@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! fixed-in-8.0.80 and removed fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Aug 2, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-entry Entry community ✨ Community Contribution fixed-in-8.0.80 fixed-in-net9.0-nightly This may be available in a nightly release!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling Focus() on an Entry befor it has been displayed causes ClearButton to be displayed permanently

5 participants