UD 2.6 checkbox not checking

I have been using 2.3 and was excited seeing Adams post about release 2.6.
But i get errors using a page with a checkbox. The code example was from docs i believe.
ps: 5.1 .net: 4.7.2 UD: 2.6
Code:
$dashboard = New-UDDashboard -Content {
New-UDElement -Id “CheckboxState” -Tag “span”
New-UDCheckbox -Id CheckBox -Label “Check me” -OnChange {
$Element = Get-UDElement -Id CheckBox
Set-UDElement -Id “CheckboxState” -Content $Element
}

}

Start-UDDashboard -Dashboard $dashboard -Port 10001 -AutoReload

Error:

I removed UD 2.6 and imported UD 2.3.2 and the checkbox does not show checked when clicked.

Hi @progmatic looking on poshud.com the example is

New-UDCheckbox -Label “Checkbox” -OnChange {
Show-UDToast -Message $EventData
}

I have my versions installed side by side but I believe the poshud site is running 2.6.0 and checkboxes working on the site

Weird.
I do have the same issue than OP.
Also, poshud.com checkboxes are not working for me at all (Tried Firefox / Chrome / IE)

@progmatic
Your use of the checkbox is correct.
I do think it is broken.
I opened a ticket on Github.

Thanks @itfranck I saw this whilst having a smoke outside, so only had the iphone to hand to try and tackle this issue. So sitting here with my laptop that is still not running 2.6.0 looking at the poshud site and the checkbox showing the checked state has the following CSS in the before state:-

[type="checkbox"]:checked + span:not(.lever)::before {
	border-bottom: 2px solid #3f51b5;
	border-right: 2px solid #3f51b5;
} 

So if either yourself or @progmatic could try and add this as custom CSS in powershell format:-

'[type="checkbox"]:checked + span:not(.lever)::after' = @{
	"border-bottom" = "2px solid #3f51b5"
	"border-right" = "2px solid #3f51b5"
} 

Hopefully this will solve your issue, or check and see if this is in the default theme…is it just the default theme you guys have tried this in? I get a feeling it’s css as in FIREFOX it displays the toast when I tick the box, just no tick mark, but that is controlled by CSS on what it shows inside, and the css setting i just pasted is that setting. I really hope this works keep me posted. Peace

From a display only perspective the checkbox on 2.6.0 is working for me. The issue is thought the New-UDInputField is always returning a string type rather than a boolean type for checkbox field. See issue 1095.

I tried both the css version and Powershell theme version and it didn’t change anything for me.

The binding work though but only produce $true for the EventData

with powershell theme modification
$Theme = New-UDTheme -Name 'ax' -Parent 'Default' -Definition @{
    '[type="checkbox"]:checked + span:not(.lever)::before' = @{
        "border-bottom" = "2px solid #3f51b5"
        "border-right"  = "2px solid #3f51b5"
    };
    '[type="checkbox"]:checked + span:not(.lever)::after'  = @{
        "border-bottom" = "2px solid #3f51b5"
        "border-right"  = "2px solid #3f51b5"
    } 
}


$dashboard = New-UDDashboard -Content {
    New-UDElement -Id “CheckboxState” -Tag “span”
    New-UDCheckbox -Label "Checkbox" -Checked

    New-UDCheckbox -Label “Checkbox” -OnChange {
        Show-UDToast -Message $EventData
    }

} -Theme $Theme


Start-UDDashboard -Dashboard $dashboard -Port 10001 -Force

I found an ugly workaround

Using an UDElement container and Sync-Element, you can flip the checked state based on a session variable.

That being said, session variable are kind of broken in 2.6 (I also opened a bug a few days earlier) so you’d have to put them in a cache variable and manage individual sessions.

 New-UDElement -Tag 'div' -Id 'chk1' -Endpoint {
        New-UDCheckbox -Label 'meh' -Checked:$Cache:Checked  -OnChange { Sync-UDElement -Id 'chk1'; $Cache:Checked = -not $Cache:Checked }
    }

A way simple approah would be to use the New-UDMuCheckbox instead which work fine as of now.

1 Like

This has been resolved in 2.6.1. I’ll get a release out this week.

1 Like

Is that freedom weeks that start at Sunday, or the superior metric weeks that starts at Monday? Because you are running out of hours real quick :wink:

lol. I guess next week…freedom weeks start on Monday in my book. I’m still in India and it’s nearly Monday here so I was rounding up.

1 Like

Pulled the nightly release and the checkbox is working. Thanks!
One day i’ll hopefully be able to contribute. So much to learn, so little time. :slight_smile:

1 Like