Is -autofocus working for anyone?

Is -autofocus working for anyone?

avatar
(anonymous user)

Any Ideas on why this isn’t working?

New-UDDashboard -Title 'End User Search' -DefaultTheme dark -Content {
    $DefaultSearch = ""
    if ($Enduser -ne $null)
    {
        $DefaultSearch = $Enduser
        New-UDTypography -Text "URL invoked search for ($Enduser)" -variant h6
    }
    New-UDGrid -Container -Content {
        New-UDGrid -Item -ExtraSmallSize 3 -Content {
            New-UDCard -Title "Search SAMACCONTNAME" -Content {
                New-UDForm -Id 'usersearchform' -Content {
                    New-UDTextbox -Id 'txtTextField' -Value $DefaultSearch -Autofocus
                } -OnSubmit {
                    Show-UDToast -Message $EventData.txtTextField
                }
            }
        }
    }
}


Product: PowerShell Universal
Version: 2.10.2


All Comments (3)

avatar

been away from Universal so long that I cant even remember the basics “-Autofocus only work in dynamic regions”

Autofocus on Input fields and buttons - Universal Dashboard / Universal Dashboard Help - Ironman Software Forums

So @Adam Driscoll back in the day we had to define dynamic stuff in -endpoints {}, instead of -content {}. is that not really a thing in PSU?

How does -autofocus work in PSU?

Select-udelement in the end of a page will do the trick for “autofocus” but I’m still wondering how to use -autofocus correctly.

avatar

We’ve got a casing but here. The PS script is setting “autofocus” while the JavaScript component is expecting “autoFocus”. You can actually work around this by creating a hashtable directly.

@{
  type = 'mu-textbox'
  id         = 'txtTextField'
  autoFocus  = $true
}


No need for any dynamics. Pages are always dynamic now.

Adam Driscoll
PowerShell Expert and Developer at Devolutions

avatar

Can you please elaborate? How should this hashtable be applied?
Would this way be working for UDAutocomplete as well?

Thanks in advance