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 ruleP2universalStack: react
uxmenusscrolledge-cases
Close overlay menus on scroll when the trigger is not sticky
If a dropdown/layer menu's anchor scrolls out of view (non-sticky header), close the menu on scroll so it doesn't float detached over the page. Account for this case explicitly rather than assuming a sticky anchor.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const onScroll = () => { if (window.innerWidth < BREAKPOINT) return; }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const onScroll = () => { |
| 2 | if (window.innerWidth < BREAKPOINT) return; |
| 3 | if (!isSticky) closeLayer(); |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)