Search code examples
angular-dartmaterialbutton

How to prevent click event propagation


When using a material button inside a container and you click on the material button, it triggers the material button event handler, but then it propagates up to the container. What is the recommended way to stop the event from propagating beyond the material button?


Solution

  • event.stopPropagation() will stop it propagating.

    event.preventDefault() stops any native action the event would have.

    https://api.dart.dev/stable/2.8.3/dart-html/Event-class.html