diff --git a/src/UniversalDashboard.Materialize/Components/ud-modal.jsx b/src/UniversalDashboard.Materialize/Components/ud-modal.jsx index 02fcc367..f5e202df 100644 --- a/src/UniversalDashboard.Materialize/Components/ud-modal.jsx +++ b/src/UniversalDashboard.Materialize/Components/ud-modal.jsx @@ -64,6 +64,11 @@ export default class UdModal extends React.Component { } onClose() { + this.setState({ + content: null, + header: null, + footer: null + }); this._instance.close(); } diff --git a/src/UniversalDashboard.Materialize/Tests/modal.tests.ps1 b/src/UniversalDashboard.Materialize/Tests/modal.tests.ps1 new file mode 100644 index 00000000..eac4f918 --- /dev/null +++ b/src/UniversalDashboard.Materialize/Tests/modal.tests.ps1 @@ -0,0 +1,43 @@ +Describe "Modal" { + Context "Show-UDModal" { + Set-TestDashboard -Content { + New-UDButton -Text "Show" -Id 'button' -OnClick { + Show-UDModal -Content { + New-UDElement -Tag 'div' -Id 'modal-content' + } + } + } + + It "should open modal with new content" { + $Element = Find-SeElement -Driver $Driver -Id 'button' + Invoke-SeClick -Element $Element + + Find-SeElement -Driver $Driver -Id 'modal-content' | Should not be $null + } + } + + Context "Hide-UDModal" { + Set-TestDashboard -Content { + New-UDButton -Text "Show" -Id 'button' -OnClick { + Show-UDModal -Content { + New-UDElement -Tag 'div' -Id 'modal-content' + New-UDButton -OnClick { Hide-UDModal } -Text "Hide" -Id 'hide' + } + } + } + + It "should dispose of content when hidden" { + $Element = Find-SeElement -Driver $Driver -Id 'button' + Invoke-SeClick -Element $Element + + Find-SeElement -Driver $Driver -Id 'modal-content' | Should not be $null + + $Element = Find-SeElement -Driver $Driver -Id 'hide' + Invoke-SeClick -Element $Element + + Start-Sleep 1 + + Find-SeElement -Driver $Driver -Id 'modal-content' | Should be $null + } + } +} \ No newline at end of file