Overview
onClickAway(fn) fires on mousedown outside the component host — the standard pattern for dismissing dropdowns, popovers, and menus.
onFocus / onBlur listen on window for the browser window gaining or losing focus (not individual inputs). Use template @focus / @blur for element-level focus.
Focus & dismiss
|
API
|
Target
|
Notes
|
|---|---|---|
onClickAway(fn)
| document mousedown | Fires when click target is outside the host element. |
onFocus(fn)
| window focus | Browser/tab regained focus — not per-element. |
onBlur(fn)
| window blur | Browser/tab lost focus. |
Dropdown with onClickAway
onClickAway registers a document-level listener that fires whenever the user clicks outside the component's root element. The listener is removed automatically on unmount — no manual cleanup needed.