Issue with UDStepper not picking up UDslider value set by a dynamic

I have a slider as a part of a stepper that is enabled/disabled by a checkbox.
I want to set the slider value to zero when it’s in the disabled state. However the stepper doesn’t pick up the new value, while I can confirm that the value is actually zero with Get-UDElement.

Maybe my logic is flawed, I’ve been changing strategies back and forth but still have the issue remaining when the stepper completes. What am I missing?

$Pages = @()

$Pages += New-UDPage -Name ‘Test2’ -Content {

New-UDTypography -Text "Hello"

} -NavigationLayout permanent

$Pages += New-UDPage -Name “Stepperpage” -Content {

New-UDStepper -Id 'DbgStepper' -Steps {

    New-UDStep -Label "Step1" -OnLoad {

        New-UDTypography -Text "Step1"

        New-UDHtml -Markup "<P>"

        New-UDCheckBox -Label 'Disk 1' -Id 'Disk1chk' -Checked $true -OnChange {

            Sync-UDElement -Id 'Disk1Elmnt'

        }#UDCheckbox

        

        $Session:Disk1Size = 5

        New-UDDynamic -Id Disk1Elmnt -Content {

            $Checked = (Get-UDElement -Id 'Disk1chk').Checked

            If($Checked){

                New-UDSlider -Id 'Disk1' -Minimum 5 -Maximum 800 -Value $Session:Disk1Size -Disabled:$Disabled -OnChange {

                    $Session:Disk1Size = (Get-UDElement -Id Disk1).value

                    Sync-UDElement -Id Disk1Text

                }#UDSlider

            }else{

                $Session:Disk1Size = 0

                New-UDSlider -Id 'Disk1' -Minimum 0 -Maximum 0 -Value $Session:Disk1Size -Disabled

                Sync-UDElement -Id Disk1

            }#If

            Sync-UDElement -Id Disk1Text

        }#UDDynamic

        New-UDDynamic -Id Disk1Text -Content {

            If((Get-UDElement -Id 'Disk1chk').Checked){

                New-UDTypography -Text "$Session:Disk1Size (GB)"

            }else {

                New-UDTypography -Text "None"

            }#If

            New-UDTypography -Text "$(Get-UDElement -Id Disk1)"

        }#UDDynamic

    }#Step

    New-UDStep -Label "Step2" -OnLoad {

        New-UDTypography -Text "Step2"

    }#Step

} -OnValidateStep {

    New-UDValidationResult -Valid

} -OnFinish {

    New-UDTypography -Text "$body"

}#Stepper

} -NavigationLayout permanent #Page

New-UDDashboard -Title “Debug Slider - Stepper!” -Pages $Pages

Product: PowerShell Universal
Version: 1.5.11

Sorry for the bump 6 months later, but did you ever get this working? I’m trying to get dynamic elements to populate in a stepper as well and this is the only topic I’ve found with someone else trying to do this.

Hi Jared,

Now my memory is cloudy as I haven’t been working with Universal for a while. I removed the checkboxes completely since I couldn’t find a way around the problem at the time and since we stopped further development of this dashboard for other reasons, I haven’t tried to figure out what’s wrong. However revisiting things like these can sometimes shed new light on the problem.

One thing that I would look into is to have some logic that checks if the Slider exists and change that existing object rather than recreating it every time the checkbox changes.

I hope you’ll find a solution or that you can get a solution from Adam. I’m very curious even though I’m not doing any development in Universal at the moment.