New-UDElement Attributes.onClick event has empty $eventData

Product: PowerShell Universal
Version: 3.6.2
Hosted: IIS and MSI

When i put an -OnClick on a button the event data has data in it, however…
When i try to put a click event on an icon, my event data is $null, what am i doing wrong?

Example

New-UDDashboard -Title 'PowerShell Universal' -Content {
    $files = dir c:\temp | select -Property PSPath, Root, FullName

    $columns = @(
        New-UDTableColumn -Title "Action" -Property action -Render {
            New-UDButton -Text 'Toast Event Data' -OnClick {
                Show-UDToast -message $eventdata.FullName
            }

            New-UDElement -Tag div -Content {
                New-UDIcon -Icon "file" -Size lg
            } -Attributes @{
                onClick = {
                    Show-UDToast $eventdata.FullName
                }
            }
        }
        New-UDTableColumn -Property PSPath
        New-UDTableColumn -Property Root
        New-UDTableColumn -Property FullName
    )
    New-UDTable -Data $files -Columns $columns
}

Success - Clicking Button

Failed - Clicking Icon

Not sure why that’s happening but here’s a work around. I’d consider this behavior a bug.

            $OtherVar = $EVentData

            New-UDElement -Tag div -Content {
                New-UDIcon -Icon "file" -Size lg
            } -Attributes @{
                onClick = {
                    Show-UDToast $OtherVar.FullName
                }
            }
1 Like