Skip to content

Commit

Permalink
Fix label overlap issue when value is provided (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattselle authored and adamdriscoll committed Dec 5, 2019
1 parent 2c9ff55 commit 758079e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}
}
8 changes: 7 additions & 1 deletion src/UniversalDashboard/Controls/src/textbox.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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 }
}
}
Expand Down

0 comments on commit 758079e

Please sign in to comment.