Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete closing when clicking scrollbar in IE #30

Closed
rtejaya opened this issue Jun 24, 2019 · 1 comment
Closed

Autocomplete closing when clicking scrollbar in IE #30

rtejaya opened this issue Jun 24, 2019 · 1 comment

Comments

@rtejaya
Copy link

rtejaya commented Jun 24, 2019

Autocomplete closing when clicking scrollbar in Internet Explorer, but this issue can't be replicated in Chrome.

@denis-taran
Copy link
Owner

Thank you for reporting, but IE has a market share of only 1.57% according to the statcounter, so only critical issues will be fixed in the future.

denis-taran pushed a commit that referenced this issue Apr 6, 2020
Prevents the autocomplete from closing in IE when its scrollbar is
clicked.

See https://stackoverflow.com/a/9210267/13172349 for more information on
the how and why.
jivdhaliwal pushed a commit to jivdhaliwal/autocomplete that referenced this issue Jan 27, 2023
diff --git a/autocomplete.js b/autocomplete.js
index 688adfd..2a2da92 100644
--- a/autocomplete.js
+++ b/autocomplete.js
@@ -223,22 +223,7 @@
                 e.preventDefault();
             }
         }
-        function keyupEventHandler(ev) {
-            var keyCode = ev.which || ev.keyCode || 0;
-            var ignore = settings.keysToIgnore || [38 /* Up */, 13 /* Enter */, 27 /* Esc */, 39 /* Right */, 37 /* Left */, 16 /* Shift */, 17 /* Ctrl */, 18 /* Alt */, 20 /* CapsLock */, 91 /* WindowsKey */, 9 /* Tab */];
-            for (var _i = 0, ignore_1 = ignore; _i < ignore_1.length; _i++) {
-                var key = ignore_1[_i];
-                if (keyCode === key) {
-                    return;
-                }
-            }
-            if (keyCode >= 112 /* F1 */ && keyCode <= 123 /* F12 */ && !settings.keysToIgnore) {
-                return;
-            }
-            // the down key is used to open autocomplete
-            if (keyCode === 40 /* Down */ && containerDisplayed()) {
-                return;
-            }
+        function inputEventHandler() {
             startFetch(0 /* Keyboard */);
         }
         /**
@@ -391,7 +376,7 @@
         function destroy() {
             input.removeEventListener("focus", focusEventHandler);
             input.removeEventListener("keydown", keydownEventHandler);
-            input.removeEventListener("keyup", keyupEventHandler);
+            input.removeEventListener("input", inputEventHandler);
             input.removeEventListener("blur", blurEventHandler);
             window.removeEventListener("resize", resizeEventHandler);
             doc.removeEventListener("scroll", scrollEventHandler, true);
@@ -407,7 +392,7 @@
         }
         // setup event handlers
         input.addEventListener("keydown", keydownEventHandler);
-        input.addEventListener("keyup", keyupEventHandler);
+        input.addEventListener("input", inputEventHandler);
         input.addEventListener("blur", blurEventHandler);
         input.addEventListener("focus", focusEventHandler);
         window.addEventListener("resize", resizeEventHandler);
diff --git a/autocomplete.js.map b/autocomplete.js.map
index d5be8c9..979c741 100644
--- a/autocomplete.js.map
+++ b/autocomplete.js.map
@@ -1 +1 @@
-{"version":3,"file":"autocomplete.js","sources":["autocomplete.ts"],"sourcesContent":["/*\n * https://github.com/kraaden/autocomplete\n * Copyright (c) 2016 Denys Krasnoshchok\n * MIT License\n */\n\nexport const enum EventTrigger {\n    Keyboard = 0,\n    Focus = 1\n}\n\nexport interface AutocompleteItem {\n    label?: string;\n    group?: string;\n}\n\nexport interface AutocompleteSettings<T extends AutocompleteItem> {\n    /**\n     * Autocomplete will be attached to this element.\n     */\n    input: HTMLInputElement | HTMLTextAreaElement;\n\n    /**\n     * Provide your own container for the widget.\n     * If not specified, a new DIV element will be created.\n     */\n    container?: HTMLDivElement;\n\n    /**\n     * This method allows you to override the default rendering function for items.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    render?: (item: T, currentValue: string, index: number) => HTMLDivElement | undefined;\n\n    /**\n     * This method allows you to override the default rendering function for item groups.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    renderGroup?: (name: string, currentValue: string) => HTMLDivElement | undefined;\n\n    /**\n     * If specified, the autocomplete DOM element will have this class assigned to it.\n     */\n    className?: string;\n\n    /**\n     * Specify the minimum text length required to show autocomplete.\n     */\n    minLength?: number;\n\n    /**\n     * The message that will be showed when there are no suggestions that match the entered value.\n     */\n    emptyMsg?: string;\n\n    /**\n     * This method will be called when user choose an item in autocomplete. The selected item will be passed as the first parameter.\n     */\n    onSelect: (item: T, input: HTMLInputElement | HTMLTextAreaElement) => void;\n\n    /**\n     * Show autocomplete on focus event. Focus event will ignore the `minLength` property and will always call `fetch`.\n     */\n    showOnFocus?: boolean;\n\n    /**\n     * This method will be called to prepare suggestions and then pass them to autocomplete.\n     * @param {string} text - text in the input field\n     * @param {(items: T[] | false) => void} update - a callback function that must be called after suggestions are prepared\n     * @param {EventTrigger} trigger - type of the event that triggered the fetch\n     * @param {number} cursorPos - position of the cursor in the input field\n     */\n    fetch: (text: string, update: (items: T[] | false) => void, trigger: EventTrigger, cursorPos: number) => void;\n\n    /**\n     * Enforces that the fetch function will only be called once within the specified time frame (in milliseconds) and\n     * delays execution. This prevents flooding your server with AJAX requests.\n     */\n    debounceWaitMs?: number;\n\n    /**\n     * Callback for additional autocomplete customization\n     * @param {HTMLInputElement | HTMLTextAreaElement} input - input box associated with autocomplete\n     * @param {ClientRect | DOMRect} inputRect - size of the input box and its position relative to the viewport\n     * @param {HTMLDivElement} container - container with suggestions\n     * @param {number} maxHeight - max height that can be used by autocomplete\n     */\n    customize?: (input: HTMLInputElement | HTMLTextAreaElement, inputRect: ClientRect | DOMRect, container: HTMLDivElement, maxHeight: number) => void;\n\n    /**\n     * Prevents automatic form submit when ENTER is pressed\n     */\n    preventSubmit?: boolean;\n\n    /**\n     * Prevents the first item in the list from being selected automatically. This option allows you\n     * to submit a custom text by pressing ENTER even when autocomplete is displayed.\n     */\n    disableAutoSelect?: boolean;\n\n    /**\n     * Keys that will be ignored and not trigger the fetch callback.\n     */\n    keysToIgnore?: Keys[];\n}\n\nexport interface AutocompleteResult {\n    destroy: () => void;\n}\n\nexport const enum Keys {\n    Enter = 13,\n    Esc = 27,\n    Up = 38,\n    Down = 40,\n    Left = 37,\n    Right = 39,\n    Shift = 16,\n    Ctrl = 17,\n    Alt = 18,\n    CapsLock = 20,\n    WindowsKey = 91,\n    Tab = 9,\n    F1 = 112,\n    F12 = 123\n}\n\nexport default function autocomplete<T extends AutocompleteItem>(settings: AutocompleteSettings<T>): AutocompleteResult {\n\n    // just an alias to minimize JS file size\n    const doc = document;\n\n    const container: HTMLDivElement = settings.container || doc.createElement(\"div\");\n    container.id = container.id || \"autocomplete-\" + uid();\n    const containerStyle = container.style;\n    const debounceWaitMs = settings.debounceWaitMs || 0;\n    const preventSubmit = settings.preventSubmit || false;\n    const disableAutoSelect = settings.disableAutoSelect || false;\n\n    let items: T[] = [];\n    let inputValue = \"\";\n    let minLen = 2;\n    const showOnFocus = settings.showOnFocus;\n    let selected: T | undefined;\n    let keypressCounter = 0;\n    let debounceTimer: number | undefined;\n\n    if (settings.minLength !== undefined) {\n        minLen = settings.minLength;\n    }\n\n    if (!settings.input) {\n        throw new Error(\"input undefined\");\n    }\n\n    const input: HTMLInputElement | HTMLTextAreaElement = settings.input;\n\n    container.className = \"autocomplete \" + (settings.className || \"\");\n    container.setAttribute(\"role\", \"listbox\");\n\n    input.setAttribute(\"role\", \"combobox\");\n    input.setAttribute(\"aria-expanded\", \"false\");\n    input.setAttribute(\"aria-autocomplete\", \"list\");\n    input.setAttribute(\"aria-controls\", container.id);\n    input.setAttribute(\"aria-owns\", container.id);\n    input.setAttribute(\"aria-activedescendant\", \"\");\n    input.setAttribute(\"aria-haspopup\", \"listbox\");\n\n    // IOS implementation for fixed positioning has many bugs, so we will use absolute positioning\n    containerStyle.position = \"absolute\";\n\n    /**\n     * Generate a unique ID\n     */\n    function uid(): string {\n        return Date.now().toString(36) + Math.random().toString(36).substring(2);\n    }\n\n    /**\n     * Detach the container from DOM\n     */\n    function detach(): void {\n        const parent = container.parentNode;\n        if (parent) {\n            parent.removeChild(container);\n        }\n    }\n\n    /**\n     * Clear debouncing timer if assigned\n     */\n    function clearDebounceTimer(): void {\n        if (debounceTimer) {\n            window.clearTimeout(debounceTimer);\n        }\n    }\n\n    /**\n     * Attach the container to DOM\n     */\n    function attach(): void {\n        if (!container.parentNode) {\n            doc.body.appendChild(container);\n        }\n    }\n\n    /**\n     * Check if container for autocomplete is displayed\n     */\n    function containerDisplayed(): boolean {\n        return !!container.parentNode;\n    }\n\n    /**\n     * Clear autocomplete state and hide container\n     */\n    function clear(): void {\n        // prevent the update call if there are pending AJAX requests\n        keypressCounter++;\n\n        items = [];\n        inputValue = \"\";\n        selected = undefined;\n        input.setAttribute(\"aria-activedescendant\", \"\");\n        input.setAttribute(\"aria-expanded\", \"false\");\n        detach();\n    }\n\n    /**\n     * Update autocomplete position\n     */\n    function updatePosition(): void {\n        if (!containerDisplayed()) {\n            return;\n        }\n\n        input.setAttribute(\"aria-expanded\", \"true\");\n\n        containerStyle.height = \"auto\";\n        containerStyle.width = input.offsetWidth + \"px\";\n\n        let maxHeight = 0;\n        let inputRect: ClientRect | DOMRect | undefined;\n\n        function calc() {\n            const docEl = doc.documentElement as HTMLElement;\n            const clientTop = docEl.clientTop || doc.body.clientTop || 0;\n            const clientLeft = docEl.clientLeft || doc.body.clientLeft || 0;\n            const scrollTop = window.pageYOffset || docEl.scrollTop;\n            const scrollLeft = window.pageXOffset || docEl.scrollLeft;\n\n            inputRect = input.getBoundingClientRect();\n\n            const top = inputRect.top + input.offsetHeight + scrollTop - clientTop;\n            const left = inputRect.left + scrollLeft - clientLeft;\n\n            containerStyle.top = top + \"px\";\n            containerStyle.left = left + \"px\";\n\n            maxHeight = window.innerHeight - (inputRect.top + input.offsetHeight);\n\n            if (maxHeight < 0) {\n                maxHeight = 0;\n            }\n\n            containerStyle.top = top + \"px\";\n            containerStyle.bottom = \"\";\n            containerStyle.left = left + \"px\";\n            containerStyle.maxHeight = maxHeight + \"px\";\n        }\n\n        // the calc method must be called twice, otherwise the calculation may be wrong on resize event (chrome browser)\n        calc();\n        calc();\n\n        if (settings.customize && inputRect) {\n            settings.customize(input, inputRect, container, maxHeight);\n        }\n    }\n\n    /**\n     * Redraw the autocomplete div element with suggestions\n     */\n    function update(): void {\n\n        // delete all children from autocomplete DOM container\n        while (container.firstChild) {\n            container.removeChild(container.firstChild);\n        }\n\n        input.setAttribute(\"aria-activedescendant\", \"\");\n\n        // function for rendering autocomplete suggestions\n        let render = function (item: T, _: string, __: number): HTMLDivElement | undefined {\n            const itemElement = doc.createElement(\"div\");\n            itemElement.textContent = item.label || \"\";\n            return itemElement;\n        };\n        if (settings.render) {\n            render = settings.render;\n        }\n\n        // function to render autocomplete groups\n        let renderGroup = function (groupName: string, _: string): HTMLDivElement | undefined {\n            const groupDiv = doc.createElement(\"div\");\n            groupDiv.textContent = groupName;\n            return groupDiv;\n        };\n        if (settings.renderGroup) {\n            renderGroup = settings.renderGroup;\n        }\n\n        const fragment = doc.createDocumentFragment();\n        let prevGroup = \"#9?$\";\n\n        items.forEach(function (item: T, index: number): void {\n            if (item.group && item.group !== prevGroup) {\n                prevGroup = item.group;\n                const groupDiv = renderGroup(item.group, inputValue);\n                if (groupDiv) {\n                    groupDiv.className += \" group\";\n                    fragment.appendChild(groupDiv);\n                }\n            }\n            const div = render(item, inputValue, index);\n            if (div) {\n                div.id = `${container.id}_${index}`;\n                div.setAttribute(\"role\", \"option\");\n                div.addEventListener(\"click\", function (ev: MouseEvent): void {\n                    settings.onSelect(item, input);\n                    clear();\n                    ev.preventDefault();\n                    ev.stopPropagation();\n                });\n                if (item === selected) {\n                    div.className += \" selected\";\n                    div.setAttribute(\"aria-selected\", \"true\");\n                    input.setAttribute(\"aria-activedescendant\", div.id);\n                }\n                fragment.appendChild(div);\n            }\n        });\n        container.appendChild(fragment);\n        if (items.length < 1) {\n            if (settings.emptyMsg) {\n                const empty = doc.createElement(\"div\");\n                empty.id = `${container.id}_${uid()}`;\n                empty.className = \"empty\";\n                empty.textContent = settings.emptyMsg;\n                container.appendChild(empty);\n                input.setAttribute(\"aria-activedescendant\", empty.id);\n            } else {\n                clear();\n                return;\n            }\n        }\n\n        attach();\n        updatePosition();\n\n        updateScroll();\n    }\n\n    function updateIfDisplayed(): void {\n        if (containerDisplayed()) {\n            update();\n        }\n    }\n\n    function resizeEventHandler(): void {\n        updateIfDisplayed();\n    }\n\n    function scrollEventHandler(e: Event): void {\n        if (e.target !== container) {\n            updateIfDisplayed();\n        } else {\n            e.preventDefault();\n        }\n    }\n\n    function keyupEventHandler(ev: KeyboardEvent): void {\n        const keyCode = ev.which || ev.keyCode || 0;\n\n        const ignore = settings.keysToIgnore || [Keys.Up, Keys.Enter, Keys.Esc, Keys.Right, Keys.Left, Keys.Shift, Keys.Ctrl, Keys.Alt, Keys.CapsLock, Keys.WindowsKey, Keys.Tab];\n        for (const key of ignore) {\n            if (keyCode === key) {\n                return;\n            }\n        }\n\n        if (keyCode >= Keys.F1 && keyCode <= Keys.F12 && !settings.keysToIgnore) {\n            return;\n        }\n\n        // the down key is used to open autocomplete\n        if (keyCode === Keys.Down && containerDisplayed()) {\n            return;\n        }\n\n        startFetch(EventTrigger.Keyboard);\n    }\n\n    /**\n     * Automatically move scroll bar if selected item is not visible\n     */\n    function updateScroll(): void {\n        const elements = container.getElementsByClassName(\"selected\");\n        if (elements.length > 0) {\n            let element = elements[0] as HTMLDivElement;\n\n            // make group visible\n            const previous = element.previousElementSibling as HTMLDivElement;\n            if (previous && previous.className.indexOf(\"group\") !== -1 && !previous.previousElementSibling) {\n                element = previous;\n            }\n\n            if (element.offsetTop < container.scrollTop) {\n                container.scrollTop = element.offsetTop;\n            } else {\n                const selectBottom = element.offsetTop + element.offsetHeight;\n                const containerBottom = container.scrollTop + container.offsetHeight;\n                if (selectBottom > containerBottom) {\n                    container.scrollTop += selectBottom - containerBottom;\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the previous item in suggestions\n     */\n    function selectPrev(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        } else {\n            if (selected === items[0]) {\n                selected = items[items.length - 1];\n            } else {\n                for (let i = items.length - 1; i > 0; i--) {\n                    if (selected === items[i] || i === 1) {\n                        selected = items[i - 1];\n                        break;\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the next item in suggestions\n     */\n    function selectNext(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        }\n        if (!selected || selected === items[items.length - 1]) {\n            selected = items[0];\n            return;\n        }\n        for (let i = 0; i < (items.length - 1); i++) {\n            if (selected === items[i]) {\n                selected = items[i + 1];\n                break;\n            }\n        }\n    }\n\n    function keydownEventHandler(ev: KeyboardEvent): void {\n        const keyCode = ev.which || ev.keyCode || 0;\n\n        if (keyCode === Keys.Up || keyCode === Keys.Down || keyCode === Keys.Esc) {\n            const containerIsDisplayed = containerDisplayed();\n\n            if (keyCode === Keys.Esc) {\n                clear();\n            } else {\n                if (!containerIsDisplayed || items.length < 1) {\n                    return;\n                }\n                keyCode === Keys.Up\n                    ? selectPrev()\n                    : selectNext();\n                update();\n            }\n\n            ev.preventDefault();\n            if (containerIsDisplayed) {\n                ev.stopPropagation();\n            }\n\n            return;\n        }\n\n        if (keyCode === Keys.Enter) {\n            if (selected) {\n                settings.onSelect(selected, input);\n                clear();\n            }\n\n            if (preventSubmit) {\n                ev.preventDefault();\n            }\n        }\n    }\n\n    function focusEventHandler(): void {\n        if (showOnFocus) {\n            startFetch(EventTrigger.Focus);\n        }\n    }\n\n    function startFetch(trigger: EventTrigger) {\n        // If multiple keys were pressed, before we get an update from server,\n        // this may cause redrawing autocomplete multiple times after the last key was pressed.\n        // To avoid this, the number of times keyboard was pressed will be saved and checked before redraw.\n        const savedKeypressCounter = ++keypressCounter;\n\n        const inputText = input.value;\n        const cursorPos = input.selectionStart || 0;\n\n        if (inputText.length >= minLen || trigger === EventTrigger.Focus) {\n            clearDebounceTimer();\n            debounceTimer = window.setTimeout(function (): void {\n                settings.fetch(inputText, function (elements: T[] | false): void {\n                    if (keypressCounter === savedKeypressCounter && elements) {\n                        items = elements;\n                        inputValue = inputText;\n                        selected = (items.length < 1 || disableAutoSelect) ? undefined : items[0];\n                        update();\n                    }\n                }, trigger, cursorPos);\n            }, trigger === EventTrigger.Keyboard ? debounceWaitMs : 0);\n        } else {\n            clear();\n        }\n    }\n\n    function blurEventHandler(): void {\n        // we need to delay clear, because when we click on an item, blur will be called before click and remove items from DOM\n        setTimeout(() => {\n            if (doc.activeElement !== input) {\n                clear();\n            }\n        }, 200);\n    }\n\n    /**\n     * Fixes #26: on long clicks focus will be lost and onSelect method will not be called\n     */\n    container.addEventListener(\"mousedown\", function (evt: Event) {\n        evt.stopPropagation();\n        evt.preventDefault();\n    });\n\n    /**\n     * Fixes #30: autocomplete closes when scrollbar is clicked in IE\n     * See: https://stackoverflow.com/a/9210267/13172349\n     */\n    container.addEventListener(\"focus\", () => input.focus());\n\n    /**\n     * This function will remove DOM elements and clear event handlers\n     */\n    function destroy(): void {\n        input.removeEventListener(\"focus\", focusEventHandler);\n        input.removeEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"keyup\", keyupEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"blur\", blurEventHandler);\n        window.removeEventListener(\"resize\", resizeEventHandler);\n        doc.removeEventListener(\"scroll\", scrollEventHandler, true);\n        input.removeAttribute(\"role\");\n        input.removeAttribute(\"aria-expanded\");\n        input.removeAttribute(\"aria-autocomplete\");\n        input.removeAttribute(\"aria-controls\");\n        input.removeAttribute(\"aria-activedescendant\");\n        input.removeAttribute(\"aria-owns\");\n        input.removeAttribute(\"aria-haspopup\");\n        clearDebounceTimer();\n        clear();\n    }\n\n    // setup event handlers\n    input.addEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"keyup\", keyupEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"blur\", blurEventHandler);\n    input.addEventListener(\"focus\", focusEventHandler);\n    window.addEventListener(\"resize\", resizeEventHandler);\n    doc.addEventListener(\"scroll\", scrollEventHandler, true);\n\n    return {\n        destroy\n    };\n}\n"],"names":[],"mappings":";;;;;;IAAA;;;;;aA+HwB,YAAY,CAA6B,QAAiC;;QAG9F,IA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AmB,CAAC,CAAC;YAC3C,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;YACvC,KAAK,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;YAC/C,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACnC,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;YACvC,kBAAkB,EAAE,CAAC;YACrB,KAAK,EAAE,CAAC;SACX;;QAGD,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,mBAAyD,CAAC,CAAC;QAC7F,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAuD,CAAC,CAAC;QACzF,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACjD,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACnD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QACtD,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAEzD,OAAO;YACH,OAAO,SAAA;SACV,CAAC;IACN;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"autocomplete.js","sources":["autocomplete.ts"],"sourcesContent":["/*\n * https://github.com/kraaden/autocomplete\n * Copyright (c) 2016 Denys Krasnoshchok\n * MIT License\n */\n\nexport const enum EventTrigger {\n    Keyboard = 0,\n    Focus = 1\n}\n\nexport interface AutocompleteItem {\n    label?: string;\n    group?: string;\n}\n\nexport interface AutocompleteSettings<T extends AutocompleteItem> {\n    /**\n     * Autocomplete will be attached to this element.\n     */\n    input: HTMLInputElement | HTMLTextAreaElement;\n\n    /**\n     * Provide your own container for the widget.\n     * If not specified, a new DIV element will be created.\n     */\n    container?: HTMLDivElement;\n\n    /**\n     * This method allows you to override the default rendering function for items.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    render?: (item: T, currentValue: string, index: number) => HTMLDivElement | undefined;\n\n    /**\n     * This method allows you to override the default rendering function for item groups.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    renderGroup?: (name: string, currentValue: string) => HTMLDivElement | undefined;\n\n    /**\n     * If specified, the autocomplete DOM element will have this class assigned to it.\n     */\n    className?: string;\n\n    /**\n     * Specify the minimum text length required to show autocomplete.\n     */\n    minLength?: number;\n\n    /**\n     * The message that will be showed when there are no suggestions that match the entered value.\n     */\n    emptyMsg?: string;\n\n    /**\n     * This method will be called when user choose an item in autocomplete. The selected item will be passed as the first parameter.\n     */\n    onSelect: (item: T, input: HTMLInputElement | HTMLTextAreaElement) => void;\n\n    /**\n     * Show autocomplete on focus event. Focus event will ignore the `minLength` property and will always call `fetch`.\n     */\n    showOnFocus?: boolean;\n\n    /**\n     * This method will be called to prepare suggestions and then pass them to autocomplete.\n     * @param {string} text - text in the input field\n     * @param {(items: T[] | false) => void} update - a callback function that must be called after suggestions are prepared\n     * @param {EventTrigger} trigger - type of the event that triggered the fetch\n     * @param {number} cursorPos - position of the cursor in the input field\n     */\n    fetch: (text: string, update: (items: T[] | false) => void, trigger: EventTrigger, cursorPos: number) => void;\n\n    /**\n     * Enforces that the fetch function will only be called once within the specified time frame (in milliseconds) and\n     * delays execution. This prevents flooding your server with AJAX requests.\n     */\n    debounceWaitMs?: number;\n\n    /**\n     * Callback for additional autocomplete customization\n     * @param {HTMLInputElement | HTMLTextAreaElement} input - input box associated with autocomplete\n     * @param {ClientRect | DOMRect} inputRect - size of the input box and its position relative to the viewport\n     * @param {HTMLDivElement} container - container with suggestions\n     * @param {number} maxHeight - max height that can be used by autocomplete\n     */\n    customize?: (input: HTMLInputElement | HTMLTextAreaElement, inputRect: ClientRect | DOMRect, container: HTMLDivElement, maxHeight: number) => void;\n\n    /**\n     * Prevents automatic form submit when ENTER is pressed\n     */\n    preventSubmit?: boolean;\n\n    /**\n     * Prevents the first item in the list from being selected automatically. This option allows you\n     * to submit a custom text by pressing ENTER even when autocomplete is displayed.\n     */\n    disableAutoSelect?: boolean;\n\n    /**\n     * Keys that will be ignored and not trigger the fetch callback.\n     */\n    keysToIgnore?: Keys[];\n}\n\nexport interface AutocompleteResult {\n    destroy: () => void;\n}\n\nexport const enum Keys {\n    Enter = 13,\n    Esc = 27,\n    Up = 38,\n    Down = 40,\n    Left = 37,\n    Right = 39,\n    Shift = 16,\n    Ctrl = 17,\n    Alt = 18,\n    CapsLock = 20,\n    WindowsKey = 91,\n    Tab = 9,\n    F1 = 112,\n    F12 = 123\n}\n\nexport default function autocomplete<T extends AutocompleteItem>(settings: AutocompleteSettings<T>): AutocompleteResult {\n\n    // just an alias to minimize JS file size\n    const doc = document;\n\n    const container: HTMLDivElement = settings.container || doc.createElement(\"div\");\n    container.id = container.id || \"autocomplete-\" + uid();\n    const containerStyle = container.style;\n    const debounceWaitMs = settings.debounceWaitMs || 0;\n    const preventSubmit = settings.preventSubmit || false;\n    const disableAutoSelect = settings.disableAutoSelect || false;\n\n    let items: T[] = [];\n    let inputValue = \"\";\n    let minLen = 2;\n    const showOnFocus = settings.showOnFocus;\n    let selected: T | undefined;\n    let keypressCounter = 0;\n    let debounceTimer: number | undefined;\n\n    if (settings.minLength !== undefined) {\n        minLen = settings.minLength;\n    }\n\n    if (!settings.input) {\n        throw new Error(\"input undefined\");\n    }\n\n    const input: HTMLInputElement | HTMLTextAreaElement = settings.input;\n\n    container.className = \"autocomplete \" + (settings.className || \"\");\n    container.setAttribute(\"role\", \"listbox\");\n\n    input.setAttribute(\"role\", \"combobox\");\n    input.setAttribute(\"aria-expanded\", \"false\");\n    input.setAttribute(\"aria-autocomplete\", \"list\");\n    input.setAttribute(\"aria-controls\", container.id);\n    input.setAttribute(\"aria-owns\", container.id);\n    input.setAttribute(\"aria-activedescendant\", \"\");\n    input.setAttribute(\"aria-haspopup\", \"listbox\");\n\n    // IOS implementation for fixed positioning has many bugs, so we will use absolute positioning\n    containerStyle.position = \"absolute\";\n\n    /**\n     * Generate a unique ID\n     */\n    function uid(): string {\n        return Date.now().toString(36) + Math.random().toString(36).substring(2);\n    }\n\n    /**\n     * Detach the container from DOM\n     */\n    function detach(): void {\n        const parent = container.parentNode;\n        if (parent) {\n            parent.removeChild(container);\n        }\n    }\n\n    /**\n     * Clear debouncing timer if assigned\n     */\n    function clearDebounceTimer(): void {\n        if (debounceTimer) {\n            window.clearTimeout(debounceTimer);\n        }\n    }\n\n    /**\n     * Attach the container to DOM\n     */\n    function attach(): void {\n        if (!container.parentNode) {\n            doc.body.appendChild(container);\n        }\n    }\n\n    /**\n     * Check if container for autocomplete is displayed\n     */\n    function containerDisplayed(): boolean {\n        return !!container.parentNode;\n    }\n\n    /**\n     * Clear autocomplete state and hide container\n     */\n    function clear(): void {\n        // prevent the update call if there are pending AJAX requests\n        keypressCounter++;\n\n        items = [];\n        inputValue = \"\";\n        selected = undefined;\n        input.setAttribute(\"aria-activedescendant\", \"\");\n        input.setAttribute(\"aria-expanded\", \"false\");\n        detach();\n    }\n\n    /**\n     * Update autocomplete position\n     */\n    function updatePosition(): void {\n        if (!containerDisplayed()) {\n            return;\n        }\n\n        input.setAttribute(\"aria-expanded\", \"true\");\n\n        containerStyle.height = \"auto\";\n        containerStyle.width = input.offsetWidth + \"px\";\n\n        let maxHeight = 0;\n        let inputRect: ClientRect | DOMRect | undefined;\n\n        function calc() {\n            const docEl = doc.documentElement as HTMLElement;\n            const clientTop = docEl.clientTop || doc.body.clientTop || 0;\n            const clientLeft = docEl.clientLeft || doc.body.clientLeft || 0;\n            const scrollTop = window.pageYOffset || docEl.scrollTop;\n            const scrollLeft = window.pageXOffset || docEl.scrollLeft;\n\n            inputRect = input.getBoundingClientRect();\n\n            const top = inputRect.top + input.offsetHeight + scrollTop - clientTop;\n            const left = inputRect.left + scrollLeft - clientLeft;\n\n            containerStyle.top = top + \"px\";\n            containerStyle.left = left + \"px\";\n\n            maxHeight = window.innerHeight - (inputRect.top + input.offsetHeight);\n\n            if (maxHeight < 0) {\n                maxHeight = 0;\n            }\n\n            containerStyle.top = top + \"px\";\n            containerStyle.bottom = \"\";\n            containerStyle.left = left + \"px\";\n            containerStyle.maxHeight = maxHeight + \"px\";\n        }\n\n        // the calc method must be called twice, otherwise the calculation may be wrong on resize event (chrome browser)\n        calc();\n        calc();\n\n        if (settings.customize && inputRect) {\n            settings.customize(input, inputRect, container, maxHeight);\n        }\n    }\n\n    /**\n     * Redraw the autocomplete div element with suggestions\n     */\n    function update(): void {\n\n        // delete all children from autocomplete DOM container\n        while (container.firstChild) {\n            container.removeChild(container.firstChild);\n        }\n\n        input.setAttribute(\"aria-activedescendant\", \"\");\n\n        // function for rendering autocomplete suggestions\n        let render = function (item: T, _: string, __: number): HTMLDivElement | undefined {\n            const itemElement = doc.createElement(\"div\");\n            itemElement.textContent = item.label || \"\";\n            return itemElement;\n        };\n        if (settings.render) {\n            render = settings.render;\n        }\n\n        // function to render autocomplete groups\n        let renderGroup = function (groupName: string, _: string): HTMLDivElement | undefined {\n            const groupDiv = doc.createElement(\"div\");\n            groupDiv.textContent = groupName;\n            return groupDiv;\n        };\n        if (settings.renderGroup) {\n            renderGroup = settings.renderGroup;\n        }\n\n        const fragment = doc.createDocumentFragment();\n        let prevGroup = \"#9?$\";\n\n        items.forEach(function (item: T, index: number): void {\n            if (item.group && item.group !== prevGroup) {\n                prevGroup = item.group;\n                const groupDiv = renderGroup(item.group, inputValue);\n                if (groupDiv) {\n                    groupDiv.className += \" group\";\n                    fragment.appendChild(groupDiv);\n                }\n            }\n            const div = render(item, inputValue, index);\n            if (div) {\n                div.id = `${container.id}_${index}`;\n                div.setAttribute(\"role\", \"option\");\n                div.addEventListener(\"click\", function (ev: MouseEvent): void {\n                    settings.onSelect(item, input);\n                    clear();\n                    ev.preventDefault();\n                    ev.stopPropagation();\n                });\n                if (item === selected) {\n                    div.className += \" selected\";\n                    div.setAttribute(\"aria-selected\", \"true\");\n                    input.setAttribute(\"aria-activedescendant\", div.id);\n                }\n                fragment.appendChild(div);\n            }\n        });\n        container.appendChild(fragment);\n        if (items.length < 1) {\n            if (settings.emptyMsg) {\n                const empty = doc.createElement(\"div\");\n                empty.id = `${container.id}_${uid()}`;\n                empty.className = \"empty\";\n                empty.textContent = settings.emptyMsg;\n                container.appendChild(empty);\n                input.setAttribute(\"aria-activedescendant\", empty.id);\n            } else {\n                clear();\n                return;\n            }\n        }\n\n        attach();\n        updatePosition();\n\n        updateScroll();\n    }\n\n    function updateIfDisplayed(): void {\n        if (containerDisplayed()) {\n            update();\n        }\n    }\n\n    function resizeEventHandler(): void {\n        updateIfDisplayed();\n    }\n\n    function scrollEventHandler(e: Event): void {\n        if (e.target !== container) {\n            updateIfDisplayed();\n        } else {\n            e.preventDefault();\n        }\n    }\n\n    function inputEventHandler(): void {\n        startFetch(EventTrigger.Keyboard);\n    }\n\n    /**\n     * Automatically move scroll bar if selected item is not visible\n     */\n    function updateScroll(): void {\n        const elements = container.getElementsByClassName(\"selected\");\n        if (elements.length > 0) {\n            let element = elements[0] as HTMLDivElement;\n\n            // make group visible\n            const previous = element.previousElementSibling as HTMLDivElement;\n            if (previous && previous.className.indexOf(\"group\") !== -1 && !previous.previousElementSibling) {\n                element = previous;\n            }\n\n            if (element.offsetTop < container.scrollTop) {\n                container.scrollTop = element.offsetTop;\n            } else {\n                const selectBottom = element.offsetTop + element.offsetHeight;\n                const containerBottom = container.scrollTop + container.offsetHeight;\n                if (selectBottom > containerBottom) {\n                    container.scrollTop += selectBottom - containerBottom;\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the previous item in suggestions\n     */\n    function selectPrev(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        } else {\n            if (selected === items[0]) {\n                selected = items[items.length - 1];\n            } else {\n                for (let i = items.length - 1; i > 0; i--) {\n                    if (selected === items[i] || i === 1) {\n                        selected = items[i - 1];\n                        break;\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the next item in suggestions\n     */\n    function selectNext(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        }\n        if (!selected || selected === items[items.length - 1]) {\n            selected = items[0];\n            return;\n        }\n        for (let i = 0; i < (items.length - 1); i++) {\n            if (selected === items[i]) {\n                selected = items[i + 1];\n                break;\n            }\n        }\n    }\n\n    function keydownEventHandler(ev: KeyboardEvent): void {\n        const keyCode = ev.which || ev.keyCode || 0;\n\n        if (keyCode === Keys.Up || keyCode === Keys.Down || keyCode === Keys.Esc) {\n            const containerIsDisplayed = containerDisplayed();\n\n            if (keyCode === Keys.Esc) {\n                clear();\n            } else {\n                if (!containerIsDisplayed || items.length < 1) {\n                    return;\n                }\n                keyCode === Keys.Up\n                    ? selectPrev()\n                    : selectNext();\n                update();\n            }\n\n            ev.preventDefault();\n            if (containerIsDisplayed) {\n                ev.stopPropagation();\n            }\n\n            return;\n        }\n\n        if (keyCode === Keys.Enter) {\n            if (selected) {\n                settings.onSelect(selected, input);\n                clear();\n            }\n\n            if (preventSubmit) {\n                ev.preventDefault();\n            }\n        }\n    }\n\n    function focusEventHandler(): void {\n        if (showOnFocus) {\n            startFetch(EventTrigger.Focus);\n        }\n    }\n\n    function startFetch(trigger: EventTrigger) {\n        // If multiple keys were pressed, before we get an update from server,\n        // this may cause redrawing autocomplete multiple times after the last key was pressed.\n        // To avoid this, the number of times keyboard was pressed will be saved and checked before redraw.\n        const savedKeypressCounter = ++keypressCounter;\n\n        const inputText = input.value;\n        const cursorPos = input.selectionStart || 0;\n\n        if (inputText.length >= minLen || trigger === EventTrigger.Focus) {\n            clearDebounceTimer();\n            debounceTimer = window.setTimeout(function (): void {\n                settings.fetch(inputText, function (elements: T[] | false): void {\n                    if (keypressCounter === savedKeypressCounter && elements) {\n                        items = elements;\n                        inputValue = inputText;\n                        selected = (items.length < 1 || disableAutoSelect) ? undefined : items[0];\n                        update();\n                    }\n                }, trigger, cursorPos);\n            }, trigger === EventTrigger.Keyboard ? debounceWaitMs : 0);\n        } else {\n            clear();\n        }\n    }\n\n    function blurEventHandler(): void {\n        // we need to delay clear, because when we click on an item, blur will be called before click and remove items from DOM\n        setTimeout(() => {\n            if (doc.activeElement !== input) {\n                clear();\n            }\n        }, 200);\n    }\n\n    /**\n     * Fixes #26: on long clicks focus will be lost and onSelect method will not be called\n     */\n    container.addEventListener(\"mousedown\", function (evt: Event) {\n        evt.stopPropagation();\n        evt.preventDefault();\n    });\n\n    /**\n     * Fixes #30: autocomplete closes when scrollbar is clicked in IE\n     * See: https://stackoverflow.com/a/9210267/13172349\n     */\n    container.addEventListener(\"focus\", () => input.focus());\n\n    /**\n     * This function will remove DOM elements and clear event handlers\n     */\n    function destroy(): void {\n        input.removeEventListener(\"focus\", focusEventHandler);\n        input.removeEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"input\", inputEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"blur\", blurEventHandler);\n        window.removeEventListener(\"resize\", resizeEventHandler);\n        doc.removeEventListener(\"scroll\", scrollEventHandler, true);\n        input.removeAttribute(\"role\");\n        input.removeAttribute(\"aria-expanded\");\n        input.removeAttribute(\"aria-autocomplete\");\n        input.removeAttribute(\"aria-controls\");\n        input.removeAttribute(\"aria-activedescendant\");\n        input.removeAttribute(\"aria-owns\");\n        input.removeAttribute(\"aria-haspopup\");\n        clearDebounceTimer();\n        clear();\n    }\n\n    // setup event handlers\n    input.addEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"input\", inputEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"blur\", blurEventHandler);\n    input.addEventListener(\"focus\", focusEventHandler);\n    window.addEventListener(\"resize\", resizeEventHandler);\n    doc.addEventListener(\"scroll\", scrollEventHandler, true);\n\n    return {\n        destroy\n    };\n}\n"],"names":[],"mappings":";;;;;;IAAA;;;;;aA+HwB,YAAY,CAA6B,QAAiC;;QAG9F,IAAM,GAAG,GAAG,QAAQ,CAAC;QAErB,IAAM,SAAS,GAAmB,QAAQ,CAAC,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC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AC,CAAC;QACtD,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAEzD,OAAO;YACH,OAAO,SAAA;SACV,CAAC;IACN;;;;;;;;"}
\ No newline at end of file
diff --git a/autocomplete.min.js b/autocomplete.min.js
index 50791be..01fac54 100644
--- a/autocomplete.min.js
+++ b/autocomplete.min.js
@@ -1,2 +1,2 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).autocomplete=t()}(this,(function(){"use strict";return function(e){var t=document,n=e.container||t.createElement("div");n.id=n.id||"autocomplete-"+m();var i,o,r=n.style,a=e.debounceWaitMs||0,s=e.preventSubmit||!1,u=e.disableAutoSelect||!1,d=[],l="",c=2,f=e.showOnFocus,p=0;if(void 0!==e.minLength&&(c=e.minLength),!e.input)throw new Error("input undefined");var v=e.input;function m(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function g(){o&&window.clearTimeout(o)}function h(){return!!n.parentNode}function b(){var e;p++,d=[],l="",i=void 0,v.setAttribute("aria-activedescendant",""),v.setAttribute("aria-expanded","false"),(e=n.parentNode)&&e.removeChild(n)}function w(){for(;n.firstChild;)n.removeChild(n.firstChild);v.setAttribute("aria-activedescendant","");var o=function(e,n,i){var o=t.createElement("div");return o.textContent=e.label||"",o};e.render&&(o=e.render);var a=function(e,n){var i=t.createElement("div");return i.textContent=e,i};e.renderGroup&&(a=e.renderGroup);…
jivdhaliwal pushed a commit to jivdhaliwal/autocomplete that referenced this issue Jan 30, 2023
Previously we were using the keyup event to decide when to fetch
autocomplete results. This approach resulted in us having to declare a
list of keys to ignore to avoid unecessary / unintended fetches.

Instead of listening for keyup events, we can simply listen for changes to
the text in the input field and fetch based on that.

This approach allows many forms of input that may not trigger a keyup event.
For example right clicking and pasting from clipboard, or tapping a autocorrect
suggestion on a mobile device.

diff --git a/autocomplete.js b/autocomplete.js
index 688adfd..2a2da92 100644
--- a/autocomplete.js
+++ b/autocomplete.js
@@ -223,22 +223,7 @@
                 e.preventDefault();
             }
         }
-        function keyupEventHandler(ev) {
-            var keyCode = ev.which || ev.keyCode || 0;
-            var ignore = settings.keysToIgnore || [38 /* Up */, 13 /* Enter */, 27 /* Esc */, 39 /* Right */, 37 /* Left */, 16 /* Shift */, 17 /* Ctrl */, 18 /* Alt */, 20 /* CapsLock */, 91 /* WindowsKey */, 9 /* Tab */];
-            for (var _i = 0, ignore_1 = ignore; _i < ignore_1.length; _i++) {
-                var key = ignore_1[_i];
-                if (keyCode === key) {
-                    return;
-                }
-            }
-            if (keyCode >= 112 /* F1 */ && keyCode <= 123 /* F12 */ && !settings.keysToIgnore) {
-                return;
-            }
-            // the down key is used to open autocomplete
-            if (keyCode === 40 /* Down */ && containerDisplayed()) {
-                return;
-            }
+        function inputEventHandler() {
             startFetch(0 /* Keyboard */);
         }
         /**
@@ -391,7 +376,7 @@
         function destroy() {
             input.removeEventListener("focus", focusEventHandler);
             input.removeEventListener("keydown", keydownEventHandler);
-            input.removeEventListener("keyup", keyupEventHandler);
+            input.removeEventListener("input", inputEventHandler);
             input.removeEventListener("blur", blurEventHandler);
             window.removeEventListener("resize", resizeEventHandler);
             doc.removeEventListener("scroll", scrollEventHandler, true);
@@ -407,7 +392,7 @@
         }
         // setup event handlers
         input.addEventListener("keydown", keydownEventHandler);
-        input.addEventListener("keyup", keyupEventHandler);
+        input.addEventListener("input", inputEventHandler);
         input.addEventListener("blur", blurEventHandler);
         input.addEventListener("focus", focusEventHandler);
         window.addEventListener("resize", resizeEventHandler);
diff --git a/autocomplete.js.map b/autocomplete.js.map
index d5be8c9..979c741 100644
--- a/autocomplete.js.map
+++ b/autocomplete.js.map
@@ -1 +1 @@
-{"version":3,"file":"autocomplete.js","sources":["autocomplete.ts"],"sourcesContent":["/*\n * https://github.com/kraaden/autocomplete\n * Copyright (c) 2016 Denys Krasnoshchok\n * MIT License\n */\n\nexport const enum EventTrigger {\n    Keyboard = 0,\n    Focus = 1\n}\n\nexport interface AutocompleteItem {\n    label?: string;\n    group?: string;\n}\n\nexport interface AutocompleteSettings<T extends AutocompleteItem> {\n    /**\n     * Autocomplete will be attached to this element.\n     */\n    input: HTMLInputElement | HTMLTextAreaElement;\n\n    /**\n     * Provide your own container for the widget.\n     * If not specified, a new DIV element will be created.\n     */\n    container?: HTMLDivElement;\n\n    /**\n     * This method allows you to override the default rendering function for items.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    render?: (item: T, currentValue: string, index: number) => HTMLDivElement | undefined;\n\n    /**\n     * This method allows you to override the default rendering function for item groups.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    renderGroup?: (name: string, currentValue: string) => HTMLDivElement | undefined;\n\n    /**\n     * If specified, the autocomplete DOM element will have this class assigned to it.\n     */\n    className?: string;\n\n    /**\n     * Specify the minimum text length required to show autocomplete.\n     */\n    minLength?: number;\n\n    /**\n     * The message that will be showed when there are no suggestions that match the entered value.\n     */\n    emptyMsg?: string;\n\n    /**\n     * This method will be called when user choose an item in autocomplete. The selected item will be passed as the first parameter.\n     */\n    onSelect: (item: T, input: HTMLInputElement | HTMLTextAreaElement) => void;\n\n    /**\n     * Show autocomplete on focus event. Focus event will ignore the `minLength` property and will always call `fetch`.\n     */\n    showOnFocus?: boolean;\n\n    /**\n     * This method will be called to prepare suggestions and then pass them to autocomplete.\n     * @param {string} text - text in the input field\n     * @param {(items: T[] | false) => void} update - a callback function that must be called after suggestions are prepared\n     * @param {EventTrigger} trigger - type of the event that triggered the fetch\n     * @param {number} cursorPos - position of the cursor in the input field\n     */\n    fetch: (text: string, update: (items: T[] | false) => void, trigger: EventTrigger, cursorPos: number) => void;\n\n    /**\n     * Enforces that the fetch function will only be called once within the specified time frame (in milliseconds) and\n     * delays execution. This prevents flooding your server with AJAX requests.\n     */\n    debounceWaitMs?: number;\n\n    /**\n     * Callback for additional autocomplete customization\n     * @param {HTMLInputElement | HTMLTextAreaElement} input - input box associated with autocomplete\n     * @param {ClientRect | DOMRect} inputRect - size of the input box and its position relative to the viewport\n     * @param {HTMLDivElement} container - container with suggestions\n     * @param {number} maxHeight - max height that can be used by autocomplete\n     */\n    customize?: (input: HTMLInputElement | HTMLTextAreaElement, inputRect: ClientRect | DOMRect, container: HTMLDivElement, maxHeight: number) => void;\n\n    /**\n     * Prevents automatic form submit when ENTER is pressed\n     */\n    preventSubmit?: boolean;\n\n    /**\n     * Prevents the first item in the list from being selected automatically. This option allows you\n     * to submit a custom text by pressing ENTER even when autocomplete is displayed.\n     */\n    disableAutoSelect?: boolean;\n\n    /**\n     * Keys that will be ignored and not trigger the fetch callback.\n     */\n    keysToIgnore?: Keys[];\n}\n\nexport interface AutocompleteResult {\n    destroy: () => void;\n}\n\nexport const enum Keys {\n    Enter = 13,\n    Esc = 27,\n    Up = 38,\n    Down = 40,\n    Left = 37,\n    Right = 39,\n    Shift = 16,\n    Ctrl = 17,\n    Alt = 18,\n    CapsLock = 20,\n    WindowsKey = 91,\n    Tab = 9,\n    F1 = 112,\n    F12 = 123\n}\n\nexport default function autocomplete<T extends AutocompleteItem>(settings: AutocompleteSettings<T>): AutocompleteResult {\n\n    // just an alias to minimize JS file size\n    const doc = document;\n\n    const container: HTMLDivElement = settings.container || doc.createElement(\"div\");\n    container.id = container.id || \"autocomplete-\" + uid();\n    const containerStyle = container.style;\n    const debounceWaitMs = settings.debounceWaitMs || 0;\n    const preventSubmit = settings.preventSubmit || false;\n    const disableAutoSelect = settings.disableAutoSelect || false;\n\n    let items: T[] = [];\n    let inputValue = \"\";\n    let minLen = 2;\n    const showOnFocus = settings.showOnFocus;\n    let selected: T | undefined;\n    let keypressCounter = 0;\n    let debounceTimer: number | undefined;\n\n    if (settings.minLength !== undefined) {\n        minLen = settings.minLength;\n    }\n\n    if (!settings.input) {\n        throw new Error(\"input undefined\");\n    }\n\n    const input: HTMLInputElement | HTMLTextAreaElement = settings.input;\n\n    container.className = \"autocomplete \" + (settings.className || \"\");\n    container.setAttribute(\"role\", \"listbox\");\n\n    input.setAttribute(\"role\", \"combobox\");\n    input.setAttribute(\"aria-expanded\", \"false\");\n    input.setAttribute(\"aria-autocomplete\", \"list\");\n    input.setAttribute(\"aria-controls\", container.id);\n    input.setAttribute(\"aria-owns\", container.id);\n    input.setAttribute(\"aria-activedescendant\", \"\");\n    input.setAttribute(\"aria-haspopup\", \"listbox\");\n\n    // IOS implementation for fixed positioning has many bugs, so we will use absolute positioning\n    containerStyle.position = \"absolute\";\n\n    /**\n     * Generate a unique ID\n     */\n    function uid(): string {\n        return Date.now().toString(36) + Math.random().toString(36).substring(2);\n    }\n\n    /**\n     * Detach the container from DOM\n     */\n    function detach(): void {\n        const parent = container.parentNode;\n        if (parent) {\n            parent.removeChild(container);\n        }\n    }\n\n    /**\n     * Clear debouncing timer if assigned\n     */\n    function clearDebounceTimer(): void {\n        if (debounceTimer) {\n            window.clearTimeout(debounceTimer);\n        }\n    }\n\n    /**\n     * Attach the container to DOM\n     */\n    function attach(): void {\n        if (!container.parentNode) {\n            doc.body.appendChild(container);\n        }\n    }\n\n    /**\n     * Check if container for autocomplete is displayed\n     */\n    function containerDisplayed(): boolean {\n        return !!container.parentNode;\n    }\n\n    /**\n     * Clear autocomplete state and hide container\n     */\n    function clear(): void {\n        // prevent the update call if there are pending AJAX requests\n        keypressCounter++;\n\n        items = [];\n        inputValue = \"\";\n        selected = undefined;\n        input.setAttribute(\"aria-activedescendant\", \"\");\n        input.setAttribute(\"aria-expanded\", \"false\");\n        detach();\n    }\n\n    /**\n     * Update autocomplete position\n     */\n    function updatePosition(): void {\n        if (!containerDisplayed()) {\n            return;\n        }\n\n        input.setAttribute(\"aria-expanded\", \"true\");\n\n        containerStyle.height = \"auto\";\n        containerStyle.width = input.offsetWidth + \"px\";\n\n        let maxHeight = 0;\n        let inputRect: ClientRect | DOMRect | undefined;\n\n        function calc() {\n            const docEl = doc.documentElement as HTMLElement;\n            const clientTop = docEl.clientTop || doc.body.clientTop || 0;\n            const clientLeft = docEl.clientLeft || doc.body.clientLeft || 0;\n            const scrollTop = window.pageYOffset || docEl.scrollTop;\n            const scrollLeft = window.pageXOffset || docEl.scrollLeft;\n\n            inputRect = input.getBoundingClientRect();\n\n            const top = inputRect.top + input.offsetHeight + scrollTop - clientTop;\n            const left = inputRect.left + scrollLeft - clientLeft;\n\n            containerStyle.top = top + \"px\";\n            containerStyle.left = left + \"px\";\n\n            maxHeight = window.innerHeight - (inputRect.top + input.offsetHeight);\n\n            if (maxHeight < 0) {\n                maxHeight = 0;\n            }\n\n            containerStyle.top = top + \"px\";\n            containerStyle.bottom = \"\";\n            containerStyle.left = left + \"px\";\n            containerStyle.maxHeight = maxHeight + \"px\";\n        }\n\n        // the calc method must be called twice, otherwise the calculation may be wrong on resize event (chrome browser)\n        calc();\n        calc();\n\n        if (settings.customize && inputRect) {\n            settings.customize(input, inputRect, container, maxHeight);\n        }\n    }\n\n    /**\n     * Redraw the autocomplete div element with suggestions\n     */\n    function update(): void {\n\n        // delete all children from autocomplete DOM container\n        while (container.firstChild) {\n            container.removeChild(container.firstChild);\n        }\n\n        input.setAttribute(\"aria-activedescendant\", \"\");\n\n        // function for rendering autocomplete suggestions\n        let render = function (item: T, _: string, __: number): HTMLDivElement | undefined {\n            const itemElement = doc.createElement(\"div\");\n            itemElement.textContent = item.label || \"\";\n            return itemElement;\n        };\n        if (settings.render) {\n            render = settings.render;\n        }\n\n        // function to render autocomplete groups\n        let renderGroup = function (groupName: string, _: string): HTMLDivElement | undefined {\n            const groupDiv = doc.createElement(\"div\");\n            groupDiv.textContent = groupName;\n            return groupDiv;\n        };\n        if (settings.renderGroup) {\n            renderGroup = settings.renderGroup;\n        }\n\n        const fragment = doc.createDocumentFragment();\n        let prevGroup = \"#9?$\";\n\n        items.forEach(function (item: T, index: number): void {\n            if (item.group && item.group !== prevGroup) {\n                prevGroup = item.group;\n                const groupDiv = renderGroup(item.group, inputValue);\n                if (groupDiv) {\n                    groupDiv.className += \" group\";\n                    fragment.appendChild(groupDiv);\n                }\n            }\n            const div = render(item, inputValue, index);\n            if (div) {\n                div.id = `${container.id}_${index}`;\n                div.setAttribute(\"role\", \"option\");\n                div.addEventListener(\"click\", function (ev: MouseEvent): void {\n                    settings.onSelect(item, input);\n                    clear();\n                    ev.preventDefault();\n                    ev.stopPropagation();\n                });\n                if (item === selected) {\n                    div.className += \" selected\";\n                    div.setAttribute(\"aria-selected\", \"true\");\n                    input.setAttribute(\"aria-activedescendant\", div.id);\n                }\n                fragment.appendChild(div);\n            }\n        });\n        container.appendChild(fragment);\n        if (items.length < 1) {\n            if (settings.emptyMsg) {\n                const empty = doc.createElement(\"div\");\n                empty.id = `${container.id}_${uid()}`;\n                empty.className = \"empty\";\n                empty.textContent = settings.emptyMsg;\n                container.appendChild(empty);\n                input.setAttribute(\"aria-activedescendant\", empty.id);\n            } else {\n                clear();\n                return;\n            }\n        }\n\n        attach();\n        updatePosition();\n\n        updateScroll();\n    }\n\n    function updateIfDisplayed(): void {\n        if (containerDisplayed()) {\n            update();\n        }\n    }\n\n    function resizeEventHandler(): void {\n        updateIfDisplayed();\n    }\n\n    function scrollEventHandler(e: Event): void {\n        if (e.target !== container) {\n            updateIfDisplayed();\n        } else {\n            e.preventDefault();\n        }\n    }\n\n    function keyupEventHandler(ev: KeyboardEvent): void {\n        const keyCode = ev.which || ev.keyCode || 0;\n\n        const ignore = settings.keysToIgnore || [Keys.Up, Keys.Enter, Keys.Esc, Keys.Right, Keys.Left, Keys.Shift, Keys.Ctrl, Keys.Alt, Keys.CapsLock, Keys.WindowsKey, Keys.Tab];\n        for (const key of ignore) {\n            if (keyCode === key) {\n                return;\n            }\n        }\n\n        if (keyCode >= Keys.F1 && keyCode <= Keys.F12 && !settings.keysToIgnore) {\n            return;\n        }\n\n        // the down key is used to open autocomplete\n        if (keyCode === Keys.Down && containerDisplayed()) {\n            return;\n        }\n\n        startFetch(EventTrigger.Keyboard);\n    }\n\n    /**\n     * Automatically move scroll bar if selected item is not visible\n     */\n    function updateScroll(): void {\n        const elements = container.getElementsByClassName(\"selected\");\n        if (elements.length > 0) {\n            let element = elements[0] as HTMLDivElement;\n\n            // make group visible\n            const previous = element.previousElementSibling as HTMLDivElement;\n            if (previous && previous.className.indexOf(\"group\") !== -1 && !previous.previousElementSibling) {\n                element = previous;\n            }\n\n            if (element.offsetTop < container.scrollTop) {\n                container.scrollTop = element.offsetTop;\n            } else {\n                const selectBottom = element.offsetTop + element.offsetHeight;\n                const containerBottom = container.scrollTop + container.offsetHeight;\n                if (selectBottom > containerBottom) {\n                    container.scrollTop += selectBottom - containerBottom;\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the previous item in suggestions\n     */\n    function selectPrev(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        } else {\n            if (selected === items[0]) {\n                selected = items[items.length - 1];\n            } else {\n                for (let i = items.length - 1; i > 0; i--) {\n                    if (selected === items[i] || i === 1) {\n                        selected = items[i - 1];\n                        break;\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the next item in suggestions\n     */\n    function selectNext(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        }\n        if (!selected || selected === items[items.length - 1]) {\n            selected = items[0];\n            return;\n        }\n        for (let i = 0; i < (items.length - 1); i++) {\n            if (selected === items[i]) {\n                selected = items[i + 1];\n                break;\n            }\n        }\n    }\n\n    function keydownEventHandler(ev: KeyboardEvent): void {\n        const keyCode = ev.which || ev.keyCode || 0;\n\n        if (keyCode === Keys.Up || keyCode === Keys.Down || keyCode === Keys.Esc) {\n            const containerIsDisplayed = containerDisplayed();\n\n            if (keyCode === Keys.Esc) {\n                clear();\n            } else {\n                if (!containerIsDisplayed || items.length < 1) {\n                    return;\n                }\n                keyCode === Keys.Up\n                    ? selectPrev()\n                    : selectNext();\n                update();\n            }\n\n            ev.preventDefault();\n            if (containerIsDisplayed) {\n                ev.stopPropagation();\n            }\n\n            return;\n        }\n\n        if (keyCode === Keys.Enter) {\n            if (selected) {\n                settings.onSelect(selected, input);\n                clear();\n            }\n\n            if (preventSubmit) {\n                ev.preventDefault();\n            }\n        }\n    }\n\n    function focusEventHandler(): void {\n        if (showOnFocus) {\n            startFetch(EventTrigger.Focus);\n        }\n    }\n\n    function startFetch(trigger: EventTrigger) {\n        // If multiple keys were pressed, before we get an update from server,\n        // this may cause redrawing autocomplete multiple times after the last key was pressed.\n        // To avoid this, the number of times keyboard was pressed will be saved and checked before redraw.\n        const savedKeypressCounter = ++keypressCounter;\n\n        const inputText = input.value;\n        const cursorPos = input.selectionStart || 0;\n\n        if (inputText.length >= minLen || trigger === EventTrigger.Focus) {\n            clearDebounceTimer();\n            debounceTimer = window.setTimeout(function (): void {\n                settings.fetch(inputText, function (elements: T[] | false): void {\n                    if (keypressCounter === savedKeypressCounter && elements) {\n                        items = elements;\n                        inputValue = inputText;\n                        selected = (items.length < 1 || disableAutoSelect) ? undefined : items[0];\n                        update();\n                    }\n                }, trigger, cursorPos);\n            }, trigger === EventTrigger.Keyboard ? debounceWaitMs : 0);\n        } else {\n            clear();\n        }\n    }\n\n    function blurEventHandler(): void {\n        // we need to delay clear, because when we click on an item, blur will be called before click and remove items from DOM\n        setTimeout(() => {\n            if (doc.activeElement !== input) {\n                clear();\n            }\n        }, 200);\n    }\n\n    /**\n     * Fixes #26: on long clicks focus will be lost and onSelect method will not be called\n     */\n    container.addEventListener(\"mousedown\", function (evt: Event) {\n        evt.stopPropagation();\n        evt.preventDefault();\n    });\n\n    /**\n     * Fixes #30: autocomplete closes when scrollbar is clicked in IE\n     * See: https://stackoverflow.com/a/9210267/13172349\n     */\n    container.addEventListener(\"focus\", () => input.focus());\n\n    /**\n     * This function will remove DOM elements and clear event handlers\n     */\n    function destroy(): void {\n        input.removeEventListener(\"focus\", focusEventHandler);\n        input.removeEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"keyup\", keyupEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"blur\", blurEventHandler);\n        window.removeEventListener(\"resize\", resizeEventHandler);\n        doc.removeEventListener(\"scroll\", scrollEventHandler, true);\n        input.removeAttribute(\"role\");\n        input.removeAttribute(\"aria-expanded\");\n        input.removeAttribute(\"aria-autocomplete\");\n        input.removeAttribute(\"aria-controls\");\n        input.removeAttribute(\"aria-activedescendant\");\n        input.removeAttribute(\"aria-owns\");\n        input.removeAttribute(\"aria-haspopup\");\n        clearDebounceTimer();\n        clear();\n    }\n\n    // setup event handlers\n    input.addEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"keyup\", keyupEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"blur\", blurEventHandler);\n    input.addEventListener(\"focus\", focusEventHandler);\n    window.addEventListener(\"resize\", resizeEventHandler);\n    doc.addEventListener(\"scroll\", scrollEventHandler, true);\n\n    return {\n        destroy\n    };\n}\n"],"names":[],"mappings":";;;;;;IAAA;;;;;aA+HwB,YAAY,CAA6B,QAAiC;;QAG9F,IAAM,GAAG,GAAG,QAAQ,CAAC;QAErB,IAAM,SAAS,GAAmB,QAAQ,CAAC,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACjF,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,IAAI,eAAe,GAAG,GAAG,EAAE,CAAC;QACvD,IAAM,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC;QACvC,IAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,IAAI,CAAC,CAAC;QACpD,IAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,IAAI,KAAK,CAAC;QACtD,IAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAE9D,IAAI,KAAK,GAAQ,EAAE,CAAC;QACpB,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,IAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACzC,IAAI,QAAuB,CAAC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AAC,QAAQ,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAEzD,OAAO;YACH,OAAO,SAAA;SACV,CAAC;IACN;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"autocomplete.js","sources":["autocomplete.ts"],"sourcesContent":["/*\n * https://github.com/kraaden/autocomplete\n * Copyright (c) 2016 Denys Krasnoshchok\n * MIT License\n */\n\nexport const enum EventTrigger {\n    Keyboard = 0,\n    Focus = 1\n}\n\nexport interface AutocompleteItem {\n    label?: string;\n    group?: string;\n}\n\nexport interface AutocompleteSettings<T extends AutocompleteItem> {\n    /**\n     * Autocomplete will be attached to this element.\n     */\n    input: HTMLInputElement | HTMLTextAreaElement;\n\n    /**\n     * Provide your own container for the widget.\n     * If not specified, a new DIV element will be created.\n     */\n    container?: HTMLDivElement;\n\n    /**\n     * This method allows you to override the default rendering function for items.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    render?: (item: T, currentValue: string, index: number) => HTMLDivElement | undefined;\n\n    /**\n     * This method allows you to override the default rendering function for item groups.\n     * It must return a DIV element or undefined to skip rendering.\n     */\n    renderGroup?: (name: string, currentValue: string) => HTMLDivElement | undefined;\n\n    /**\n     * If specified, the autocomplete DOM element will have this class assigned to it.\n     */\n    className?: string;\n\n    /**\n     * Specify the minimum text length required to show autocomplete.\n     */\n    minLength?: number;\n\n    /**\n     * The message that will be showed when there are no suggestions that match the entered value.\n     */\n    emptyMsg?: string;\n\n    /**\n     * This method will be called when user choose an item in autocomplete. The selected item will be passed as the first parameter.\n     */\n    onSelect: (item: T, input: HTMLInputElement | HTMLTextAreaElement) => void;\n\n    /**\n     * Show autocomplete on focus event. Focus event will ignore the `minLength` property and will always call `fetch`.\n     */\n    showOnFocus?: boolean;\n\n    /**\n     * This method will be called to prepare suggestions and then pass them to autocomplete.\n     * @param {string} text - text in the input field\n     * @param {(items: T[] | false) => void} update - a callback function that must be called after suggestions are prepared\n     * @param {EventTrigger} trigger - type of the event that triggered the fetch\n     * @param {number} cursorPos - position of the cursor in the input field\n     */\n    fetch: (text: string, update: (items: T[] | false) => void, trigger: EventTrigger, cursorPos: number) => void;\n\n    /**\n     * Enforces that the fetch function will only be called once within the specified time frame (in milliseconds) and\n     * delays execution. This prevents flooding your server with AJAX requests.\n     */\n    debounceWaitMs?: number;\n\n    /**\n     * Callback for additional autocomplete customization\n     * @param {HTMLInputElement | HTMLTextAreaElement} input - input box associated with autocomplete\n     * @param {ClientRect | DOMRect} inputRect - size of the input box and its position relative to the viewport\n     * @param {HTMLDivElement} container - container with suggestions\n     * @param {number} maxHeight - max height that can be used by autocomplete\n     */\n    customize?: (input: HTMLInputElement | HTMLTextAreaElement, inputRect: ClientRect | DOMRect, container: HTMLDivElement, maxHeight: number) => void;\n\n    /**\n     * Prevents automatic form submit when ENTER is pressed\n     */\n    preventSubmit?: boolean;\n\n    /**\n     * Prevents the first item in the list from being selected automatically. This option allows you\n     * to submit a custom text by pressing ENTER even when autocomplete is displayed.\n     */\n    disableAutoSelect?: boolean;\n\n    /**\n     * Keys that will be ignored and not trigger the fetch callback.\n     */\n    keysToIgnore?: Keys[];\n}\n\nexport interface AutocompleteResult {\n    destroy: () => void;\n}\n\nexport const enum Keys {\n    Enter = 13,\n    Esc = 27,\n    Up = 38,\n    Down = 40,\n    Left = 37,\n    Right = 39,\n    Shift = 16,\n    Ctrl = 17,\n    Alt = 18,\n    CapsLock = 20,\n    WindowsKey = 91,\n    Tab = 9,\n    F1 = 112,\n    F12 = 123\n}\n\nexport default function autocomplete<T extends AutocompleteItem>(settings: AutocompleteSettings<T>): AutocompleteResult {\n\n    // just an alias to minimize JS file size\n    const doc = document;\n\n    const container: HTMLDivElement = settings.container || doc.createElement(\"div\");\n    container.id = container.id || \"autocomplete-\" + uid();\n    const containerStyle = container.style;\n    const debounceWaitMs = settings.debounceWaitMs || 0;\n    const preventSubmit = settings.preventSubmit || false;\n    const disableAutoSelect = settings.disableAutoSelect || false;\n\n    let items: T[] = [];\n    let inputValue = \"\";\n    let minLen = 2;\n    const showOnFocus = settings.showOnFocus;\n    let selected: T | undefined;\n    let keypressCounter = 0;\n    let debounceTimer: number | undefined;\n\n    if (settings.minLength !== undefined) {\n        minLen = settings.minLength;\n    }\n\n    if (!settings.input) {\n        throw new Error(\"input undefined\");\n    }\n\n    const input: HTMLInputElement | HTMLTextAreaElement = settings.input;\n\n    container.className = \"autocomplete \" + (settings.className || \"\");\n    container.setAttribute(\"role\", \"listbox\");\n\n    input.setAttribute(\"role\", \"combobox\");\n    input.setAttribute(\"aria-expanded\", \"false\");\n    input.setAttribute(\"aria-autocomplete\", \"list\");\n    input.setAttribute(\"aria-controls\", container.id);\n    input.setAttribute(\"aria-owns\", container.id);\n    input.setAttribute(\"aria-activedescendant\", \"\");\n    input.setAttribute(\"aria-haspopup\", \"listbox\");\n\n    // IOS implementation for fixed positioning has many bugs, so we will use absolute positioning\n    containerStyle.position = \"absolute\";\n\n    /**\n     * Generate a unique ID\n     */\n    function uid(): string {\n        return Date.now().toString(36) + Math.random().toString(36).substring(2);\n    }\n\n    /**\n     * Detach the container from DOM\n     */\n    function detach(): void {\n        const parent = container.parentNode;\n        if (parent) {\n            parent.removeChild(container);\n        }\n    }\n\n    /**\n     * Clear debouncing timer if assigned\n     */\n    function clearDebounceTimer(): void {\n        if (debounceTimer) {\n            window.clearTimeout(debounceTimer);\n        }\n    }\n\n    /**\n     * Attach the container to DOM\n     */\n    function attach(): void {\n        if (!container.parentNode) {\n            doc.body.appendChild(container);\n        }\n    }\n\n    /**\n     * Check if container for autocomplete is displayed\n     */\n    function containerDisplayed(): boolean {\n        return !!container.parentNode;\n    }\n\n    /**\n     * Clear autocomplete state and hide container\n     */\n    function clear(): void {\n        // prevent the update call if there are pending AJAX requests\n        keypressCounter++;\n\n        items = [];\n        inputValue = \"\";\n        selected = undefined;\n        input.setAttribute(\"aria-activedescendant\", \"\");\n        input.setAttribute(\"aria-expanded\", \"false\");\n        detach();\n    }\n\n    /**\n     * Update autocomplete position\n     */\n    function updatePosition(): void {\n        if (!containerDisplayed()) {\n            return;\n        }\n\n        input.setAttribute(\"aria-expanded\", \"true\");\n\n        containerStyle.height = \"auto\";\n        containerStyle.width = input.offsetWidth + \"px\";\n\n        let maxHeight = 0;\n        let inputRect: ClientRect | DOMRect | undefined;\n\n        function calc() {\n            const docEl = doc.documentElement as HTMLElement;\n            const clientTop = docEl.clientTop || doc.body.clientTop || 0;\n            const clientLeft = docEl.clientLeft || doc.body.clientLeft || 0;\n            const scrollTop = window.pageYOffset || docEl.scrollTop;\n            const scrollLeft = window.pageXOffset || docEl.scrollLeft;\n\n            inputRect = input.getBoundingClientRect();\n\n            const top = inputRect.top + input.offsetHeight + scrollTop - clientTop;\n            const left = inputRect.left + scrollLeft - clientLeft;\n\n            containerStyle.top = top + \"px\";\n            containerStyle.left = left + \"px\";\n\n            maxHeight = window.innerHeight - (inputRect.top + input.offsetHeight);\n\n            if (maxHeight < 0) {\n                maxHeight = 0;\n            }\n\n            containerStyle.top = top + \"px\";\n            containerStyle.bottom = \"\";\n            containerStyle.left = left + \"px\";\n            containerStyle.maxHeight = maxHeight + \"px\";\n        }\n\n        // the calc method must be called twice, otherwise the calculation may be wrong on resize event (chrome browser)\n        calc();\n        calc();\n\n        if (settings.customize && inputRect) {\n            settings.customize(input, inputRect, container, maxHeight);\n        }\n    }\n\n    /**\n     * Redraw the autocomplete div element with suggestions\n     */\n    function update(): void {\n\n        // delete all children from autocomplete DOM container\n        while (container.firstChild) {\n            container.removeChild(container.firstChild);\n        }\n\n        input.setAttribute(\"aria-activedescendant\", \"\");\n\n        // function for rendering autocomplete suggestions\n        let render = function (item: T, _: string, __: number): HTMLDivElement | undefined {\n            const itemElement = doc.createElement(\"div\");\n            itemElement.textContent = item.label || \"\";\n            return itemElement;\n        };\n        if (settings.render) {\n            render = settings.render;\n        }\n\n        // function to render autocomplete groups\n        let renderGroup = function (groupName: string, _: string): HTMLDivElement | undefined {\n            const groupDiv = doc.createElement(\"div\");\n            groupDiv.textContent = groupName;\n            return groupDiv;\n        };\n        if (settings.renderGroup) {\n            renderGroup = settings.renderGroup;\n        }\n\n        const fragment = doc.createDocumentFragment();\n        let prevGroup = \"#9?$\";\n\n        items.forEach(function (item: T, index: number): void {\n            if (item.group && item.group !== prevGroup) {\n                prevGroup = item.group;\n                const groupDiv = renderGroup(item.group, inputValue);\n                if (groupDiv) {\n                    groupDiv.className += \" group\";\n                    fragment.appendChild(groupDiv);\n                }\n            }\n            const div = render(item, inputValue, index);\n            if (div) {\n                div.id = `${container.id}_${index}`;\n                div.setAttribute(\"role\", \"option\");\n                div.addEventListener(\"click\", function (ev: MouseEvent): void {\n                    settings.onSelect(item, input);\n                    clear();\n                    ev.preventDefault();\n                    ev.stopPropagation();\n                });\n                if (item === selected) {\n                    div.className += \" selected\";\n                    div.setAttribute(\"aria-selected\", \"true\");\n                    input.setAttribute(\"aria-activedescendant\", div.id);\n                }\n                fragment.appendChild(div);\n            }\n        });\n        container.appendChild(fragment);\n        if (items.length < 1) {\n            if (settings.emptyMsg) {\n                const empty = doc.createElement(\"div\");\n                empty.id = `${container.id}_${uid()}`;\n                empty.className = \"empty\";\n                empty.textContent = settings.emptyMsg;\n                container.appendChild(empty);\n                input.setAttribute(\"aria-activedescendant\", empty.id);\n            } else {\n                clear();\n                return;\n            }\n        }\n\n        attach();\n        updatePosition();\n\n        updateScroll();\n    }\n\n    function updateIfDisplayed(): void {\n        if (containerDisplayed()) {\n            update();\n        }\n    }\n\n    function resizeEventHandler(): void {\n        updateIfDisplayed();\n    }\n\n    function scrollEventHandler(e: Event): void {\n        if (e.target !== container) {\n            updateIfDisplayed();\n        } else {\n            e.preventDefault();\n        }\n    }\n\n    function inputEventHandler(): void {\n        startFetch(EventTrigger.Keyboard);\n    }\n\n    /**\n     * Automatically move scroll bar if selected item is not visible\n     */\n    function updateScroll(): void {\n        const elements = container.getElementsByClassName(\"selected\");\n        if (elements.length > 0) {\n            let element = elements[0] as HTMLDivElement;\n\n            // make group visible\n            const previous = element.previousElementSibling as HTMLDivElement;\n            if (previous && previous.className.indexOf(\"group\") !== -1 && !previous.previousElementSibling) {\n                element = previous;\n            }\n\n            if (element.offsetTop < container.scrollTop) {\n                container.scrollTop = element.offsetTop;\n            } else {\n                const selectBottom = element.offsetTop + element.offsetHeight;\n                const containerBottom = container.scrollTop + container.offsetHeight;\n                if (selectBottom > containerBottom) {\n                    container.scrollTop += selectBottom - containerBottom;\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the previous item in suggestions\n     */\n    function selectPrev(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        } else {\n            if (selected === items[0]) {\n                selected = items[items.length - 1];\n            } else {\n                for (let i = items.length - 1; i > 0; i--) {\n                    if (selected === items[i] || i === 1) {\n                        selected = items[i - 1];\n                        break;\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n     * Select the next item in suggestions\n     */\n    function selectNext(): void {\n        if (items.length < 1) {\n            selected = undefined;\n        }\n        if (!selected || selected === items[items.length - 1]) {\n            selected = items[0];\n            return;\n        }\n        for (let i = 0; i < (items.length - 1); i++) {\n            if (selected === items[i]) {\n                selected = items[i + 1];\n                break;\n            }\n        }\n    }\n\n    function keydownEventHandler(ev: KeyboardEvent): void {\n        const keyCode = ev.which || ev.keyCode || 0;\n\n        if (keyCode === Keys.Up || keyCode === Keys.Down || keyCode === Keys.Esc) {\n            const containerIsDisplayed = containerDisplayed();\n\n            if (keyCode === Keys.Esc) {\n                clear();\n            } else {\n                if (!containerIsDisplayed || items.length < 1) {\n                    return;\n                }\n                keyCode === Keys.Up\n                    ? selectPrev()\n                    : selectNext();\n                update();\n            }\n\n            ev.preventDefault();\n            if (containerIsDisplayed) {\n                ev.stopPropagation();\n            }\n\n            return;\n        }\n\n        if (keyCode === Keys.Enter) {\n            if (selected) {\n                settings.onSelect(selected, input);\n                clear();\n            }\n\n            if (preventSubmit) {\n                ev.preventDefault();\n            }\n        }\n    }\n\n    function focusEventHandler(): void {\n        if (showOnFocus) {\n            startFetch(EventTrigger.Focus);\n        }\n    }\n\n    function startFetch(trigger: EventTrigger) {\n        // If multiple keys were pressed, before we get an update from server,\n        // this may cause redrawing autocomplete multiple times after the last key was pressed.\n        // To avoid this, the number of times keyboard was pressed will be saved and checked before redraw.\n        const savedKeypressCounter = ++keypressCounter;\n\n        const inputText = input.value;\n        const cursorPos = input.selectionStart || 0;\n\n        if (inputText.length >= minLen || trigger === EventTrigger.Focus) {\n            clearDebounceTimer();\n            debounceTimer = window.setTimeout(function (): void {\n                settings.fetch(inputText, function (elements: T[] | false): void {\n                    if (keypressCounter === savedKeypressCounter && elements) {\n                        items = elements;\n                        inputValue = inputText;\n                        selected = (items.length < 1 || disableAutoSelect) ? undefined : items[0];\n                        update();\n                    }\n                }, trigger, cursorPos);\n            }, trigger === EventTrigger.Keyboard ? debounceWaitMs : 0);\n        } else {\n            clear();\n        }\n    }\n\n    function blurEventHandler(): void {\n        // we need to delay clear, because when we click on an item, blur will be called before click and remove items from DOM\n        setTimeout(() => {\n            if (doc.activeElement !== input) {\n                clear();\n            }\n        }, 200);\n    }\n\n    /**\n     * Fixes #26: on long clicks focus will be lost and onSelect method will not be called\n     */\n    container.addEventListener(\"mousedown\", function (evt: Event) {\n        evt.stopPropagation();\n        evt.preventDefault();\n    });\n\n    /**\n     * Fixes #30: autocomplete closes when scrollbar is clicked in IE\n     * See: https://stackoverflow.com/a/9210267/13172349\n     */\n    container.addEventListener(\"focus\", () => input.focus());\n\n    /**\n     * This function will remove DOM elements and clear event handlers\n     */\n    function destroy(): void {\n        input.removeEventListener(\"focus\", focusEventHandler);\n        input.removeEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"input\", inputEventHandler as EventListenerOrEventListenerObject);\n        input.removeEventListener(\"blur\", blurEventHandler);\n        window.removeEventListener(\"resize\", resizeEventHandler);\n        doc.removeEventListener(\"scroll\", scrollEventHandler, true);\n        input.removeAttribute(\"role\");\n        input.removeAttribute(\"aria-expanded\");\n        input.removeAttribute(\"aria-autocomplete\");\n        input.removeAttribute(\"aria-controls\");\n        input.removeAttribute(\"aria-activedescendant\");\n        input.removeAttribute(\"aria-owns\");\n        input.removeAttribute(\"aria-haspopup\");\n        clearDebounceTimer();\n        clear();\n    }\n\n    // setup event handlers\n    input.addEventListener(\"keydown\", keydownEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"input\", inputEventHandler as EventListenerOrEventListenerObject);\n    input.addEventListener(\"blur\", blurEventHandler);\n    input.addEventListener(\"focus\", focusEventHandler);\n    window.addEventListener(\"resize\", resizeEventHandler);\n    doc.addEventListener(\"scroll\", scrollEventHandler, true);\n\n    return {\n        destroy\n    };\n}\n"],"names":[],"mappings":";;;;;;IAAA;;;;;aA+HwB,YAAY,CAA6B,QAAiC;;QAG9F,IAAM,GAAG,GAAG,QAAQ,CAAC;QAErB,IAAM,SAAS,GAAmB,QAAQ,CAAC,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACjF,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,IAAI,eAAe,GAAG,GAAG,EAAE,CAAC;QACvD,IAAM,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC;QACvC,IAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,IAAI,CAAC,CAAC;QACpD,IAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,IAAI,KAAK,CAAC;QACtD,IAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAE9D,IAAI,KAAK,GAAQ,EAAE,CAAC;QACpB,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,IAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACzC,IAAI,QAAuB,CAAC;QAC5B,IAAI,eAAe,GAAG,CAAC,CAAC;QACxB,IAAI,aAAiC,CAAC;QAEtC,IAAI,QAAQ,CAAC,SAAS,KAAK,SAAS,EAAE;YAClC,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C,eAAe,CAAC,mBAAmB,CAAC,CAAC;YAC3C,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;YACvC,KAAK,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;YAC/C,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACnC,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;YACvC,kBAAkB,EAAE,CAAC;YACrB,KAAK,EAAE,CAAC;SACX;;QAGD,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,mBAAyD,CAAC,CAAC;QAC7F,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAuD,CAAC,CAAC;QACzF,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACjD,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACnD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QACtD,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAEzD,OAAO;YACH,OAAO,SAAA;SACV,CAAC;IACN;;;;;;;;"}
\ No newline at end of file
diff --git a/autocomplete.min.js b/autocomplete.min.js
index 50791be..01fac54 100644
--- a/autocomplete.min.js
+++ b/autocomplete.min.js
@@ -1,2 +1,2 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).autocomplete=t()}(this,(function(){"use strict";return function(e){var t=document,n=e.container||t.createElement("div");n.id=n.id||"autocomplete-"+m();var i,o,r=n.style,a=e.debounceWaitMs||0,s=e.preventSubmit||!1,u=e.disableAutoSelect||!1,d=[],l="",c=2,f=e.showOnFocus,p=0;if(void 0!==e.minLength&&(c=e.minLength),!e.input)throw new Error("input undefined");var v=e.input;function m(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function g(){o&&window.clearTimeou…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants