How to use the @s-ui/js/lib/dom.getCurrentElementFocused function in @s-ui/js

To help you get started, we’ve selected a few @s-ui/js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SUI-Components / sui-components / components / molecule / select / src / index.js View on Github external
const handleKeyDown = ev => {
    ev.persist()
    const isEnabledKey = ENABLED_KEYS.includes(ev.key)
    const options = refsMoleculeSelectOptions.current.map(getTarget)
    const domSourceEvent = ev.target
    const domMoleculeSelect = refMoleculeSelect.current

    if (!isOpen && isEnabledKey) {
      domSourceEvent === domMoleculeSelect && handleToggle(ev)
    } else {
      const currentElementFocused = getCurrentElementFocused()
      const isSomeOptionFocused = [...options].includes(currentElementFocused)
      if (ev.key === 'Escape') closeList(ev)
      if (ev.key === 'ArrowDown' && !isSomeOptionFocused)
        focusFirstOption(ev, {options})
    }
  }
github SUI-Components / sui-components / components / molecule / autosuggest / src / index.js View on Github external
setTimeout(() => {
      const currentElementFocused = getCurrentElementFocused()
      const focusOutFromOutside = ![domInnerInput, ...options].includes(
        currentElementFocused
      )
      if (focusOutFromOutside) {
        isOpen ? closeList(ev) : setFocus(false)
      }
    }, 1)
    setFocus(true)
github SUI-Components / sui-components / components / molecule / select / src / index.js View on Github external
setTimeout(() => {
      const currentElementFocused = getCurrentElementFocused()
      const isSomeOptionFocused = [...options].includes(currentElementFocused)
      const isOptionListFocused = firstOption
        ? currentElementFocused.isSameNode(firstOption.parentNode)
        : false

      if (!isSomeOptionFocused && !isOptionListFocused && isOpen) {
        closeList(ev)
      }
    }, 1)
    setFocus(false)

@s-ui/js

Set of JS utilities

MIT
Latest version published 2 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages