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

Button.ContentLayout="Right, xx" does not work inside of an HorizontalStackLayout #11755

Closed
rmotta01 opened this issue Nov 30, 2022 · 8 comments · Fixed by #13267
Closed

Button.ContentLayout="Right, xx" does not work inside of an HorizontalStackLayout #11755

rmotta01 opened this issue Nov 30, 2022 · 8 comments · Fixed by #13267
Assignees
Labels
area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter control-button Button, ImageButton fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/android 🤖 t/bug Something isn't working

Comments

@rmotta01
Copy link

rmotta01 commented Nov 30, 2022

Description

<?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">

    <HorizontalStackLayout>
        <Button
                Text="Hello"
                ImageSource="arrow_down_black.png"
                ContentLayout="Right,2"
                VerticalOptions="Center"/>
    </HorizontalStackLayout>

</ContentPage>

image

This is on Android. On Windows it works (it has other bug). iOS, don't know.
With FlexPanel it happens too, Also, on a Grid with columndefinton Auto.

Steps to Reproduce

Create a new project.
Add this page.
Run it.

Link to public reproduction project repository

https://github.com/rmotta01/MauiBugBtnImgSource01

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 33

Did you find any workaround?

No response

Relevant log output

No response

@rmotta01 rmotta01 added the t/bug Something isn't working label Nov 30, 2022
@Eilon Eilon added the area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Nov 30, 2022
@PureWeen PureWeen added control-button Button, ImageButton s/needs-repro Attach a solution or code which reproduces the issue labels Nov 30, 2022
@ghost
Copy link

ghost commented Nov 30, 2022

Hi @rmotta01. 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.

@rmotta01
Copy link
Author

rmotta01 commented Dec 1, 2022

Are you understaffed?

https://github.com/rmotta01/MauiBugBtnImgSource01

@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 Dec 1, 2022
@mattleibow
Copy link
Member

Thanks for the repro!

@mattleibow mattleibow added this to the Backlog milestone Dec 1, 2022
@mattleibow mattleibow removed the s/needs-attention Issue has more information and needs another look label Dec 1, 2022
@ghost
Copy link

ghost commented Dec 1, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@hartez
Copy link
Contributor

hartez commented Dec 1, 2022

Are you understaffed?

https://github.com/rmotta01/MauiBugBtnImgSource01

@rmotta01 I'm getting a 404 when trying to look at your repro - is that the correct URL?

@rmotta01
Copy link
Author

rmotta01 commented Dec 2, 2022

Sorry, It was private, now It's public.

@manojit
Copy link

manojit commented Dec 6, 2022

I observed the same behavior with the vertical stack layout too. Another interesting behavior during debugging and hot reload

  1. Try to change to Content Layout something like "Top, XX" or any other value than Right
  2. Now try "Right, XX" again

This works. However, it will not persist

@jonathanpeppers jonathanpeppers added the partner/hot-reload-xaml Issues impacting XAML Hot Reload experiences label Jan 24, 2023
@hartez
Copy link
Contributor

hartez commented Feb 1, 2023

Weird. So, from the repro project it doesn't seem like ContentLayout with the button on the Right is working correctly in any of the layouts. So this isn't specifically a HorizontalStackLayout problem.

In fact, in any of the layouts, I can make it work by setting the WidthRequest for the Button to 300. So I think the issue is directly related to the Button's width. Almost like the ContentLayout is getting broken if the Button is too narrow.

@jonathanpeppers jonathanpeppers added area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter and removed partner/hot-reload-xaml Issues impacting XAML Hot Reload experiences labels Feb 7, 2023
@BretJohnson BretJohnson self-assigned this Feb 8, 2023
BretJohnson added a commit that referenced this issue Feb 11, 2023
There seems to be an Android bug where it sometimes doesn't
compute the updated icon position correctly, treating
IconGravityTextEnd as if it were IconGravityTextStart.
Setting the Icon to null and then back again forces the
resetIconDrawable call here
https://github.com/material-components/material-components-android/blob/25b3c2b15c9b9499993d6d4a5fb491ffce04517a/lib/java/com/google/android/material/button/MaterialButton.java#L852-L869
to happen which seems to make things work properly.

Fixes #11755
PureWeen pushed a commit that referenced this issue May 14, 2023
* Set Icon to null and back again, working around Android issue

There seems to be an Android bug where it sometimes doesn't
compute the updated icon position correctly, treating
IconGravityTextEnd as if it were IconGravityTextStart.
Setting the Icon to null and then back again forces the
resetIconDrawable call here
https://github.com/material-components/material-components-android/blob/25b3c2b15c9b9499993d6d4a5fb491ffce04517a/lib/java/com/google/android/material/button/MaterialButton.java#L852-L869
to happen which seems to make things work properly.

Fixes #11755

* Add device test

* Update test so results show in window

* Update to use AttachAndRun, for performance

* Use new base class method to call AttachAndRun

* Remove unneeded InvokeOnMainThreadAsync

* Update to use CreateHandlerAndAddToWindow

* Use Theory to test all 4 icon positions

* Update the logic for Top as well
@samhouts samhouts modified the milestones: Backlog, .NET 8 May 24, 2023
rmarinho pushed a commit that referenced this issue May 30, 2023
* Set Icon to null and back again, working around Android issue

There seems to be an Android bug where it sometimes doesn't
compute the updated icon position correctly, treating
IconGravityTextEnd as if it were IconGravityTextStart.
Setting the Icon to null and then back again forces the
resetIconDrawable call here
https://github.com/material-components/material-components-android/blob/25b3c2b15c9b9499993d6d4a5fb491ffce04517a/lib/java/com/google/android/material/button/MaterialButton.java#L852-L869
to happen which seems to make things work properly.

Fixes #11755

* Add device test

* Update test so results show in window

* Update to use AttachAndRun, for performance

* Use new base class method to call AttachAndRun

* Remove unneeded InvokeOnMainThreadAsync

* Update to use CreateHandlerAndAddToWindow

* Use Theory to test all 4 icon positions

* Update the logic for Top as well
@samhouts samhouts added the fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! label Jun 21, 2023
@dotnet dotnet locked as resolved and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/controls 🎮 Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter control-button Button, ImageButton fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants