From 758079e25dce36acb690e5998bfd663f5fa1e1a4 Mon Sep 17 00:00:00 2001 From: mattselle Date: Thu, 5 Dec 2019 07:25:51 -0600 Subject: [PATCH] Fix label overlap issue when value is provided (#1348) https://github.com/ironmansoftware/universal-dashboard/issues/1330 --- .../Tests/textbox.tests.ps1 | 20 +++++++++++++++++++ .../Controls/src/textbox.ps1 | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 diff --git a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 new file mode 100644 index 00000000..1ea52902 --- /dev/null +++ b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 @@ -0,0 +1,20 @@ +Describe "Textbox" { + + Context "textbox no value" { + Set-TestDashboard -Content { + New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' + } + It "should not be active" { + Find-SeElement -ClassName 'active' -Driver $Driver | should be $null + } + } + + Context "textbox value" { + Set-TestDashboard -Content { + New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' -Value (Get-Date).ToString('yyyy.MM.dd HH:mm:ss.fff') + } + It "should be active" { + Find-SeElement -ClassName 'active' -Driver $Driver | should be $true + } + } +} \ No newline at end of file diff --git a/src/UniversalDashboard/Controls/src/textbox.ps1 b/src/UniversalDashboard/Controls/src/textbox.ps1 index 90d729c8..b3a55ea4 100644 --- a/src/UniversalDashboard/Controls/src/textbox.ps1 +++ b/src/UniversalDashboard/Controls/src/textbox.ps1 @@ -39,6 +39,11 @@ function New-UDTextbox { $Attributes.disabled = $true } + $LabelClassName = "" + if($Value){ + $LabelClassName = "active" + } + New-UDElement -Tag "div" -Attributes @{ className = 'input-field'} -Content { if ($PSBoundParameters.ContainsKey('Icon')) { @@ -50,8 +55,9 @@ function New-UDTextbox { New-UDElement -Id $Id -Tag "input" -Attributes $Attributes if ($PSBoundParameters.ContainsKey('Label')) { - New-UDElement -Tag "label" -Attributes @{ + New-UDElement -Tag "label" -Attributes @{ 'for' = $Id + className = $LabelClassName } -Content { $Label } } }