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 ruleP1universalStack: react
accessibilityuxpopoverfloating-ui
Let popovers close on outside click and Escape
A popover must be dismissible by clicking outside or pressing Escape, not only by completing the action inside it.
PR: hegnar-components · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | // only closes after a cell is selected |
| 2 | <Popover open={isOpen}>...</Popover> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const dismiss = useDismiss(context, { outsidePress: true, escapeKey: true }); |
| 2 | const { getFloatingProps } = useInteractions([dismiss]); |
| 3 | <div ref={refs.setFloating} {...getFloatingProps()}>...</div> |
Explanation (EN)
Objašnjenje (HR)