Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toggleLocatorAttributes (set) {
// We have to find the actual DOM nodes and append the attributes
// directly, as we can't be sure when safe cloning the child that
// it will accept the data attribute as a prop
this.toggleLocatorAttribute(
findDOMNode(this._content),
Position.contentLocatorAttribute,
set
)
this.toggleLocatorAttribute(
findDOMNode(this._target),
Position.targetLocatorAttribute,
set
)
}
handleKeyUp = e => {
const spaceKey = e.keyCode === keycode.codes.space
const enterKey = e.keyCode === keycode.codes.enter
if (spaceKey || enterKey) {
e.preventDefault()
e.stopPropagation()
if (spaceKey) {
findDOMNode(this._node).click() // eslint-disable-line react/no-find-dom-node
}
}
}
get defaultFocusElement () {
let { defaultFocusElement } = this.props
if (typeof defaultFocusElement === 'function') {
defaultFocusElement = defaultFocusElement()
}
if (defaultFocusElement) {
defaultFocusElement = findDOMNode(defaultFocusElement)
}
if (!defaultFocusElement) {
const tabbable = findTabbable(this._content)
defaultFocusElement = tabbable && tabbable[0]
}
error(
defaultFocusElement && defaultFocusElement.focus,
'[Page] A default focusable element is required or focus will be lost.'
)
return defaultFocusElement
}
this.element = new PositionedElement(element, placement, { top: this.options.offsetY, left: this.options.offsetX })
this.target = new PositionedElement(
target || this.container,
over ? this.element.placement : this.element.mirroredPlacement
)
if (constrain === 'window') {
this.constrainTo(ownerWindow(element))
} else if (constrain === 'scroll-parent') {
this.constrainTo(getScrollParents(this.target.node)[0])
} else if (constrain === 'parent') {
this.constrainTo(this.container)
} else if (typeof constrain === 'function') {
this.constrainTo(findDOMNode(constrain.call(null)))
} else if (typeof constrain === 'object') {
this.constrainTo(findDOMNode(constrain))
}
}
handleDialogDismiss = (...args) => {
if (!this.props.shouldReturnFocus && this.props.shouldFocusContentOnTriggerBlur) {
const trigger = findDOMNode(this._trigger)
if (trigger && typeof trigger.focus === 'function') {
trigger.focus()
}
}
this.hide(...args)
}
this.target = new PositionedElement(
target || this.container,
over ? this.element.placement : this.element.mirroredPlacement
)
if (constrain === 'window') {
this.constrainTo(ownerWindow(element))
} else if (constrain === 'scroll-parent') {
this.constrainTo(getScrollParents(this.target.node)[0])
} else if (constrain === 'parent') {
this.constrainTo(this.container)
} else if (typeof constrain === 'function') {
this.constrainTo(findDOMNode(constrain.call(null)))
} else if (typeof constrain === 'object') {
this.constrainTo(findDOMNode(constrain))
}
}
addMatchListener (query, updateMatches, match = this.props.match) {
const matchListener = match === 'element'
? addElementQueryMatchListener
: addMediaQueryMatchListener
return matchListener(query, findDOMNode(this), updateMatches)
}
focus () {
findDOMNode(this._link).focus()
}
get contentElement () {
let contentElement = findDOMNode(this.props.contentElement)
if (!contentElement) {
contentElement = findDOMNode(this._root)
}
return contentElement
}
get contentElement () {
let contentElement = findDOMNode(this.props.contentElement)
if (!contentElement) {
contentElement = findDOMNode(this._root)
}
return contentElement
}