From 6749fbc230baba47e30764046e546c064f22ac61 Mon Sep 17 00:00:00 2001 From: BoSen29 <54361737+BoSen29@users.noreply.github.com> Date: Fri, 23 Aug 2019 10:13:38 +0200 Subject: [PATCH] Add param to autofocus textbox on load. #564 Optimally the attribute should have no value. --- .../Controls/src/textbox.ps1 | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/UniversalDashboard/Controls/src/textbox.ps1 b/src/UniversalDashboard/Controls/src/textbox.ps1 index bc1d681f..233ac617 100644 --- a/src/UniversalDashboard/Controls/src/textbox.ps1 +++ b/src/UniversalDashboard/Controls/src/textbox.ps1 @@ -14,14 +14,26 @@ function New-UDTextbox { [Parameter()] [Switch]$Disabled, [Parameter()] - [UniversalDashboard.Models.FontAwesomeIcons]$Icon + [UniversalDashboard.Models.FontAwesomeIcons]$Icon, + [Switch]$Autofocus ) - $Attributes = @{ - type = $type - value = $Value - placeholder = $Placeholder + If ($Autofocus) { + $Attributes = @{ + type = $type + value = $Value + placeholder = $Placeholder + autofocus = "true" + } + } + else { + $Attributes = @{ + type = $type + value = $Value + placeholder = $Placeholder + } } + if ($Disabled) { $Attributes.disabled = $true @@ -43,4 +55,4 @@ function New-UDTextbox { } -Content { $Label } } } -} \ No newline at end of file +}