<!--
title: Control event propagation
domain: app-frameworks
topic: Networking
language: JavaScript
source: discourse/discourse
updated: 2025-08-18
url: https://awesomereviewers.com/reviewers/discourse-control-event-propagation/
-->

Prevent unintended network requests and interface conflicts by properly controlling event propagation in interactive elements. Use `event.stopImmediatePropagation()` when multiple event listeners on the same element or its ancestors could trigger conflicting network operations.

This is particularly important when:
- Form submissions or network requests could be triggered by event bubbling
- Multiple components handle the same event type and could interfere with each other
- Autocomplete or similar features need to prevent default browser behavior

Example:
```javascript
case "Enter":
case "Tab":
  event.preventDefault();
  event.stopImmediatePropagation(); // Prevents other listeners from triggering unwanted network calls
```

Consider binding events to the most appropriate element level rather than relying on event bubbling, especially for network-triggering operations like prefetching or form submissions. This reduces the risk of unintended network activity and improves code maintainability.
