use:clickoutside
Runs the callback on a pointerdown anywhere outside the element. "Outside" means !node.contains(event.target), so clicks inside descendants (including rendered portals that end up inside the node) don't fire.
Companion: use:clickoutsideonce is the same but auto-removes after the first match — useful for dismissible overlays.