Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleKeyDown = (event) => {
const {
filterText,
selectedOption,
selectedOption: { length }
} = this.state
// If the user pressed backspace while focusing on input, input is emtpy and there's selectedOptions
if (
(event.key === 'Backspace' || event.key === 'Delete') &&
length > 0 &&
filterText === '' &&
isActiveElement(this._input)
) {
this.dismiss(event, selectedOption[length - 1])
}
this.props.onKeyDown(event)
}
event.preventDefault()
return
}
// Account for a changing tabindex of the active element
// (a case that happens with Menu for KO a11y)
if (containsActiveElement(element)) {
const activeElement = getActiveElement()
if (tabbable.indexOf(activeElement) === -1) {
tabbable.push(activeElement)
}
}
const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1]
const leavingFinalTabbable = (
isActiveElement(finalTabbable) ||
// handle immediate shift+tab after opening with mouse
isActiveElement(node) ||
// already left final tabbable
!containsActiveElement(element)
)
if (!leavingFinalTabbable) return
if (typeof onLeavingFinalTabbable === 'function') {
onLeavingFinalTabbable()
return
}
event.preventDefault()
const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0]
target.focus()
}
// Account for a changing tabindex of the active element
// (a case that happens with Menu for KO a11y)
if (containsActiveElement(element)) {
const activeElement = getActiveElement()
if (tabbable.indexOf(activeElement) === -1) {
tabbable.push(activeElement)
}
}
const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1]
const leavingFinalTabbable = (
isActiveElement(finalTabbable) ||
// handle immediate shift+tab after opening with mouse
isActiveElement(node) ||
// already left final tabbable
!containsActiveElement(element)
)
if (!leavingFinalTabbable) return
if (typeof onLeavingFinalTabbable === 'function') {
onLeavingFinalTabbable()
return
}
event.preventDefault()
const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0]
target.focus()
}
get focused () {
return isActiveElement(this._button)
}
get focused () {
return isActiveElement(this._link)
}
get focused () {
return isActiveElement(this._button)
}
get focused () {
return isActiveElement(this._container)
}
get focused () {
return isActiveElement(this._button)
}
get focused () {
return this._input && isActiveElement(this._input)
}
get focused () {
return isActiveElement(this._container)
}