UDInput with explicit -Id cannot be sync'd

While not all UD objects can be used directly with Sync-UDElement, I can work around that by wrapping them in a New-UDElement -tag div and calling Sync-UDElement against that wrapper.

I had started using the -Id parameter in many New-UD* commands without otherwise needing to as a way to label those objects within my script.

But whether or not some objects can be successfully sync’d is dependent on whether or not -Id is explicitly set.

In the below example, the CredInput section is sync’d when the User selection changes. When the -Id parameter is used with New-UDInput within that section, the UserName UDInputField does not get updated. If the -Id parameter is omitted, effectively creating a UDInput with a new, random GUID each time, the UDInputField is updated successfully.

New-UDSelect -ID UserSelect -Label 'User' -Option {

    #  Dummy default select option
    New-UDSelectOption -Name 'Select user to update' -Value ' ' -Selected -Disabled

    #  Add all users as select options
    $Users | ForEach { New-UDSelectOption -Name $_ -Value $_ }
    } -OnChange {

    #  Update default user login name with selected user name
    Sync-UDElement -Id CredInput

New-UDElement -Id CredInput -Tag div -Endpoint {

# Fails
#   New-UDInput -Id UserCredInput -SubmitText 'Add user' -Content {
# Works
#   New-UDInput                   -SubmitText 'Add user' -Content {
    New-UDInput -Id UserCredInput -SubmitText 'Add user' -Content {

        #  Get selected user, if any
        $User = [string]( Get-UDElement -Id UserSelect ).Attributes.value

        New-UDInputField -Name 'UserName' -Type textbox  -Placeholder 'User login name' -DefaultValue $User
        New-UDInputField -Name 'Password' -Type password -Placeholder 'User password'