Select to view content in your preferred language

calcite components dropdown menu item selection

2239
3
Jump to solution
08-04-2021 08:48 AM
JayHill
Frequent Contributor

I'm trying to implement the new calcite components dropdown menu and can't get it to select any of the value options for the field-select.

1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

According to the doc, we need to listen to the 'calciteDropdownSelect' event on the calcite-dropdown element.  In your code you retrieve the selected item information later on, so you can use the 'selectedItems' property to discover this information.  Here's a slightly updated version of your CodePen that shows these concepts: https://codepen.io/john-grayson/pen/JjNappM 

View solution in original post

3 Replies
JohnGrayson
Esri Regular Contributor

According to the doc, we need to listen to the 'calciteDropdownSelect' event on the calcite-dropdown element.  In your code you retrieve the selected item information later on, so you can use the 'selectedItems' property to discover this information.  Here's a slightly updated version of your CodePen that shows these concepts: https://codepen.io/john-grayson/pen/JjNappM 

JayHill
Frequent Contributor

Thanks John! It still wasn't rendering but instead of "selected" for the default choice it is now "active".  All works then.

coryeicher
Frequent Contributor

For anyone coming across this and seeing 'selectedItems' forever an empty array, I found this to be the case. The solution I found was to put my calcite-dropdown-items in a calcite-dropdown-group. Nothing else needed beyond that. This was the only way I found to know when/which item is selected in a calcite dropdown.

(@JohnGrayson howdy, been awhile!)

CORY EICHER
www.eichcorp.com
cory@eichcorp.com