I have a MDC Menu component, where I would like to setup a click or select event listener for list items. I have tried with various events like 'click', 'select', 'selectionchange', 'selectstart', but none of them worked. In documentation it says that MDCMenu:selected
Used to indicate when an element has been selected. This event also includes the item selected and the list index of that item.
I have tried to listen to that event as well, but nothing has worked:
menu.listen("MDCMenu:selected", e => console.log(e));
You can see the sandbox here. How should the event listener be setup for MDC menu component?
Update
Since after I was informed in the comments that for other users the code is actually working. I went to test it myself with other browsers, and in safari and firefox it was working fine on my mac machine, but in Chrome I still have a problem. I have the chrome version 83.0.4103.61. I have updated the codesandbox with suggestions from the comments, but I can now see that if press few times select options, that it starts to work very randomly all of a sudden in all of the browsers.