Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Visual] [Material] [Android] Setting a button disabled reset the borderWidth #9262

Open
quentinR0bert opened this issue Jan 20, 2020 · 5 comments

Comments

@quentinR0bert
Copy link

Description

When we set a button disabled, the borderWidth is reset to 1.

Steps to Reproduce

  1. Declare a Style for Buttons and set a borderWidth != 1
  2. Set dynamically the button disabled
  3. The borderWidth seen is reset

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue:4.4.0.991477
@samhouts
Copy link
Member

@quentinR0bert Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts samhouts added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 23, 2020
@quentinR0bert
Copy link
Author

Hi,
So i go further in our project when i done the sample.

The issue seems to be from somewhere else : In our project we set the border color when we set a button disabled. And we have a renderer for customisation and fixing a issue we haved : the BorderWidth don't totaly work with a Material element.

We can have no border (BorderWidth = 0) and a little border (BorderWidth = 1) but if we affect another value (5 or 10) the BorderWidth visually is always one.

For iOS we set the fix in the ApplyTheme override called at each modification of a visual property. But on Android we set on the OnElementChanged since ApplyTheme doesn't exist for the Android MaterialRenderer. But if we make a modification on the border in runtime (color or width) the MaterialRenderer re-set visually to One.

In the sample there is the Renderers with only the fixing of the BorderWidth.

So the issue seems to be "BorderWidth doesn't take apply other value than zero or one". And it's our actual workaround who doesn't fix this issue with a runtime modification.
Forms44.zip

@samhouts samhouts removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 28, 2020
@PureWeen
Copy link
Contributor

So I think this is an issue on the android side that should be resolved once we update to 1.1.0

In the original spec
#4951

We reference this issue
material-components/material-components-android#129

So once we update to material 1.1.0 we can revisit

@PureWeen PureWeen removed the s/unverified New report that has yet to be verified label Feb 21, 2020
@tossingc
Copy link

@PureWeen Two questions and a workaround we are using:

  1. Any idea on a time frame for updating to material 1.1.0?

  2. Do you suspect that the below issue will also likely be addressed by updating to material 1.1.0?

    We are not using BorderWidth - we are, however, experiencing rendering issues with buttons which are disabled (looks like it may be related to this issue?):
    image

  3. Wanted to share a workaround we have in place:

    If the button starts out enabled and we switch it to disabled AFTER the page is shown, then it renders as expected:
    image

    protected override void OnAppearing()
    {
        base.OnAppearing();
        
        ApplySelectButtonCommandBindingWithoutTriggeringRenderingBug();
    }
    
    // TODO: figure out why button styling is broken unless the Button starts out enabled and is then disabled, after a delay
    private async void ApplySelectButtonCommandBindingWithoutTriggeringRenderingBug()
    {
        SelectButton.RemoveBinding(Button.CommandProperty);
        SelectButton.IsEnabled = true;
    
        // allow rendering of button
        await Task.Delay(100);
        // NOTE: Task.Yield() does not work when navigated away from page and back to it (i.e. using Shell navigation)
    
        SelectButton.IsEnabled = false;
        SelectButton.SetBinding(
            Button.CommandProperty,
            new Binding(nameof(PatientSelectionPageViewModel.SelectCommand))
        );
    }
    

@dwightbennett
Copy link

dwightbennett commented Aug 5, 2020

@tossingc I know this is months late, but i was having the same issue you're describing and when i updated xamarin forms and xamarin forms material to the latest today (4.7.0.1239) the issue was resolved.

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants