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

Maui iOS Switch, SelectBar, ToggleButton and Checkbox #1377

Open
WoodyJ007 opened this issue Feb 15, 2024 · 8 comments
Open

Maui iOS Switch, SelectBar, ToggleButton and Checkbox #1377

WoodyJ007 opened this issue Feb 15, 2024 · 8 comments

Comments

@WoodyJ007
Copy link
Contributor

Switch, SelectBar, ToggleButton, Checkbox controls do not work on Maui when deployed with release but only when published to TestFlight and Store.

I've been struggling with this for 4-5 months, app working fine on Android, Windows and iOS. I originally thought it was an issue when I upgraded to .net 8. Android and Windows were fine but iOS would crash out and no crash reports. I figured it would eventually get fixed with .net patches.

Turns out it was specific Radzen controls. I can confirm app works fine in debug and release with all the tricks of interpreter MtouchInterpreter etc.. So it's not linking, trimming or anything like that. Only after release to Test Flight and Store does it crash.

Finally found the cause today and it's 100% an issue with Switch, SelectBar and all toggling controls. No idea why, you can't reproduce with test or release. It must be a release and published to the store or test flight.

Steps to reproduce. Bind a switch or SelectBar, toggle. Deploy to test flight.

It must be bound <RadzenCheckBox @bind-Value=@SomeBool />

unbound works fine.

@WoodyJ007 WoodyJ007 changed the title Maui iOS Switch and SelectBar Maui iOS Switch, SelectBar, ToggleButton and Checkbox Feb 15, 2024
@akorchev
Copy link
Collaborator

@WoodyJ007
Copy link
Contributor Author

Check if this forum thread helps https://forum.radzen.com/t/net-maui-blazor-hybrid-with-radzen-components/16408

Nope, definitely not that. Cleaned, deleted from PC and Mac.. I've tried everything and been very meticulous as I wanted to be sure. It's 100% related to toggle controls.

@akorchev
Copy link
Collaborator

That thread mentions changes in the csproj file. Do you have them?

To be honest it is impossible for us right now to test on a real device. And if it happens on a device only we can't debug.

@WoodyJ007
Copy link
Contributor Author

That thread mentions changes in the csproj file. Do you have them?

To be honest it is impossible for us right now to test on a real device. And if it happens on a device only we can't debug.

Yes, I've done absolutely everything. It's been broken for months and last 3 days I've done nothing else but try to get to the bottom of it. I'm currently going through the project and taking these controls out and replacing with custom ones. So it's not urgent, it's just something that is happening but I have a workaround by not using those controls.

@akorchev
Copy link
Collaborator

That's very strange indeed. The Switch component is rather simple in implementation.

<div @ref="@Element" @attributes="Attributes" class="@GetCssClass()" id="@GetId()"
     @onclick="@Toggle" @onkeypress="@(async (args) => { if (args.Code == "Space") { await Toggle(); } })" style="outline: 0 none;@Style" tabindex="@(Disabled ? "-1" : $"{TabIndex}")">
    <div class="rz-helper-hidden-accessible">
            <input type="checkbox" name="@Name" id="@Name" checked="@Value" value="@ValueAsString" tabindex="-1" aria-checked="@(Value.ToString().ToLowerInvariant())" @attributes=@InputAttributes>
    </div>
    <span class="rz-switch-circle@(Disabled ? " rz-disabled" : "")"></span>
</div>

Could you try removing either @onclick or @onkeypress to see if this would work? You would need to add the Radzen.Blazor.csproj to your solution so you can build it from source.

@WoodyJ007
Copy link
Contributor Author

That's very strange indeed. The Switch component is rather simple in implementation.

<div @ref="@Element" @attributes="Attributes" class="@GetCssClass()" id="@GetId()"
     @onclick="@Toggle" @onkeypress="@(async (args) => { if (args.Code == "Space") { await Toggle(); } })" style="outline: 0 none;@Style" tabindex="@(Disabled ? "-1" : $"{TabIndex}")">
    <div class="rz-helper-hidden-accessible">
            <input type="checkbox" name="@Name" id="@Name" checked="@Value" value="@ValueAsString" tabindex="-1" aria-checked="@(Value.ToString().ToLowerInvariant())" @attributes=@InputAttributes>
    </div>
    <span class="rz-switch-circle@(Disabled ? " rz-disabled" : "")"></span>
</div>

Could you try removing either @onclick or @onkeypress to see if this would work? You would need to add the Radzen.Blazor.csproj to your solution so you can build it from source.

There isn't anything. Just a simple bind.

<RadzenCheckBox @bind-Value=@SomeBool />

When you don't bind it displays and works.

Same with Switch, SelectBar, ToggleButton etc..

You can click and toggle visually fine. As soon as you put the bind in, the app will hard crash on render. You don't even get crash reports. I caught it on the xcode device console so figured out it was something visual, then I simplified everything. An incredibly frustrating bug to find and fix as it takes about 20-30mins per build because remote mac, archving, published, rest flight etc..

Sorry that's not much help. I've worked around it for the moment by creating my own switch style control.

@WoodyJ007
Copy link
Contributor Author

WoodyJ007 commented Feb 20, 2024

Just to add further comment to this. It also affects Datepickers, drop-downs, grids and other bound controls. I know some have said clearing cache, deleting bin/obj etc works but it doesn't. I think it's a common underlying factor of all the bound controls, when they are unbound they display and behave fine, bounding is the issue so possibly some javascript or something like that that ios doesn't allow and/or something to do with Apple and packaging IPA files? I'd say PWA is the way forward but Apple clearly don't.

@akorchev
Copy link
Collaborator

RadzenSwitch doesn't use any JavaScript interop at the moment so this is probably not the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants