Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
Merge pull request #903 from ironmansoftware/872
Browse files Browse the repository at this point in the history
Fixes #872
  • Loading branch information
adamdriscoll authored Jun 24, 2019
2 parents 16db22b + 1f278a8 commit 33c9dfd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/UniversalDashboard.Materialize/Components/ud-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export default class UDSelect extends React.Component {
}

onChange(e) {
if (this.props.onChange == null) {
return
}

var val = new Array();

if (e.target.selectedOptions) {
Expand All @@ -53,16 +49,20 @@ export default class UDSelect extends React.Component {
val = JSON.stringify(val);
}

this.setState({
value: val
})

if (this.props.onChange == null) {
return
}

UniversalDashboard.publish('element-event', {
type: "clientEvent",
eventId: this.props.onChange,
eventName: 'onChange',
eventData: val
});

this.setState({
value: val
})
}

render() {
Expand Down
36 changes: 34 additions & 2 deletions src/UniversalDashboard.Materialize/Tests/select.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,45 @@ Describe "Select" {

Start-Sleep 1

$Element = Find-SeElement -XPath "//ul/li" -Element $Element | Select-Object -Skip 1 -First 1
$Element = Find-SeElement -XPath "//ul/li" -Element $Element | Select-Object -Skip 2 -First 1
Invoke-SeClick -Element $Element

$Button = Find-SeElement -Driver $Driver -Id 'btn'
Invoke-SeClick -Element $Button

Get-TestData | Should be "2"
Get-TestData | Should be "3"
}
}

Context "Get-UDElement" {
Set-TestDashboard -Content {

New-UDButton -Text "Button" -Id 'btn' -OnClick {
$Value = (Get-UDElement -Id 'test').Attributes['value']

Set-TestData -Data $Value
}

New-UDSelect -Label "Test" -Id 'test' -Option {
New-UDSelectOption -Nam "Test 1" -Value "1"
New-UDSelectOption -Nam "Test 2" -Value "2"
New-UDSelectOption -Nam "Test 3" -Value "3"
}
}

It "should select item and get it with Get-UDElement" {
$Element = Find-SeElement -ClassName "select-wrapper" -Driver $Driver | Select-Object -First 1
Invoke-SeClick -Element $Element

Start-Sleep 1

$Element = Find-SeElement -XPath "//ul/li" -Element $Element | Select-Object -Skip 2 -First 1
Invoke-SeClick -Element $Element

$Button = Find-SeElement -Driver $Driver -Id 'btn'
Invoke-SeClick -Element $Button

Get-TestData | Should be "3"
}
}
}

0 comments on commit 33c9dfd

Please sign in to comment.