UNPKG

web-ui-pack

Version:
19 lines (18 loc) 1.17 kB
export interface onFocusLostOptions extends AddEventListenerOptions { /** Required to prevent debounce when user clicks on label tied with input; * In this case events labelClick > inputFocusout > inputClick > inputFocusin is called * * Troubleshooting: if click/focusout is handled somewhere during for a long time `debounceMs` must be adjusted * or you can prevent labelOnClick behavior via adding label.addEventListener('mousedown', (e) => e.preventDefault()); * and implement labelClick > inputFocus yourself * @defaultValue 100ms */ debounceMs?: number; } /** Fires when element/children completely lost focus. * This event checks next focused/active element and isn't called several times when focus goes between children. * @param element HTMLElement to apply `.addEventListener` * @param listener Callback invoked on event * @param options OnFocusLostOptions * @return Callback with `.removeEventListener`. Call it to remove listener * */ export default function onFocusLost(element: HTMLElement, listener: (this: HTMLElement, ev: HTMLElementEventMap["focusout"]) => any, options?: onFocusLostOptions): () => void;