Issue with New-UDSelect -BrowserDefault

Hi all,

I am having an issue with New-UDSelect. If I use the -BrowserDefault option, when the selection changes I get the error “Cannot read property ‘removeEventListener’ of undefined”.

New-UDSelect -Label "Site" -BrowserDefault -Option {
                    New-UDSelectOption -Name " " -Value " "
                    $sites = get-sites
                    $sites | ForEach-Object { New-UDSelectOption -Name "$($_.site_code) $($_.site_name)" -Value "$($_.site_code)"}

                } -OnChange {
                    $Session:Site = $eventdata
                    Show-UDToast -Message "Changed to $($Session:Site)" -Duration 5000
                    Sync-UDElement -Id Heading
                }

It gets populated fine in the first place and the code in the onchange works but the drop down box gets replaced with the error text.

Any ideas? Thanks

Hey @Alc thanks for posting this question and welcome to the UD forums…this is how I roll with a select option:-

New-UDInput -Title "Select" -Id "card1" -Content {
  New-UDInputField -Type 'select' -Name 'SERVER' -Values @("Server1","Server2","Server3")
            } -Endpoint {
                param($Server)
				Set-UDElement -Id 'output' -Content {$Server}
				$Session:ServerName = $Server
				@("chart","card2","card3","card4") | Sync-UDElement
            } 

This then syncs the ID of chart,card2,card3 and card4 with the value selected.

Thanks for the reply. Can you check if this still works with the -BrowserDefault option please? My code all works fine unless I specify that option.

Just to add, the error in console is:

TypeError: Cannot read property ‘removeEventListener’ of undefined
at r.value (materialize.js:11697)
at r.value (materialize.js:11659)
at t.value (Select.js:99)
at Ra (react-dom.production.min.js:216)
at Fa (react-dom.production.min.js:220)
at react-dom.production.min.js:250
at Object.t.unstable_runWithPriority (scheduler.production.min.js:18)
at Ys (react-dom.production.min.js:250)
at Os (react-dom.production.min.js:249)
at Ss (react-dom.production.min.js:248)
ca @ react-dom.production.min.js:198
i.componentDidCatch.n.callback @ react-dom.production.min.js:211
na @ react-dom.production.min.js:193
ta @ react-dom.production.min.js:193
Ra @ react-dom.production.min.js:216
Fa @ react-dom.production.min.js:220
(anonymous) @ react-dom.production.min.js:250
t.unstable_runWithPriority @ scheduler.production.min.js:18
Ys @ react-dom.production.min.js:250
Os @ react-dom.production.min.js:249
Ss @ react-dom.production.min.js:248
Ds @ react-dom.production.min.js:250
ze @ react-dom.production.min.js:39
On @ react-dom.production.min.js:86
ListPicker._handleMouseUp
react-dom.production.min.js:198 TypeError: Cannot read property ‘removeEventListener’ of undefined
at r.value (materialize.js:11697)
at r.value (materialize.js:11659)
at t.value (Select.js:108)
at pa (react-dom.production.min.js:202)
at ya (react-dom.production.min.js:207)
at Ha (react-dom.production.min.js:214)
at Fa (react-dom.production.min.js:220)
at react-dom.production.min.js:250
at Object.t.unstable_runWithPriority (scheduler.production.min.js:18)
at Ys (react-dom.production.min.js:250)

Think it would be best to raise this as a bug on the github page. You cool to do that?

UPDATE here is the link:-
https://github.com/ironmansoftware/universal-dashboard/issues/new/choose

I can but try :smiley:

1 Like