Skip to content
Advertisement

How do I get Material-UI SpeedDialAction onClick events to fire when SpeedDial is open on click only (not hover)

For some reason, when I change material-ui <SpeedDial> to remove the prop onMouseEnter={handleOpen} so that the speed dial only opens upon clicking the FAB instead of on hover, the onClick event in <SpeedDialAction> does not get triggered when I click a speed dial menu item. I feel like I’m missing something fundamental here.

JavaScript

Advertisement

Answer

Using preventDefault will not cause the click event to not propagate to the parent element (which from what I understand is what you are trying to get).

You should use the stopPropagation instead:

JavaScript

Check the following example: https://codesandbox.io/s/speeddial-open-on-click-rleg5?file=/demo.js

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement