Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP1stack specificStack: react
reacteventsclick-handling
Stop event propagation on inner clickable handlers
Call event.stopPropagation() in handlers nested inside a clickable parent so the inner action does not also trigger the parent's click.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | <Card onClick={openThread}> |
| 2 | <MenuItem onClick={copyUrl}>Copy</MenuItem> |
| 3 | </Card> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | <Card onClick={openThread}> |
| 2 | <MenuItem onClick={(e) => { e.stopPropagation(); copyUrl(); }}>Copy</MenuItem> |
| 3 | </Card> |
Explanation (EN)
Objašnjenje (HR)