rc-dialog
Advanced tools
Comparing version 4.4.0 to 4.4.1
@@ -71,2 +71,4 @@ 'use strict'; | ||
componentDidUpdate: function componentDidUpdate(prevProps) { | ||
var _this = this; | ||
var props = this.props; | ||
@@ -85,2 +87,3 @@ var dialogDomNode = React.findDOMNode(this.refs.dialog); | ||
}); | ||
this.lastOutSideFocusNode = document.activeElement; | ||
dialogDomNode.focus(); | ||
@@ -95,2 +98,8 @@ } else if (props.align !== prevProps.align) { | ||
props.onClose(); | ||
if (props.mask && _this.lastOutSideFocusNode) { | ||
try { | ||
_this.lastOutSideFocusNode.focus(); | ||
} catch (e) {} | ||
_this.lastOutSideFocusNode = null; | ||
} | ||
}); | ||
@@ -107,5 +116,30 @@ } | ||
handleKeyDown: function handleKeyDown(e) { | ||
if (e.keyCode === KeyCode.ESC) { | ||
var props = this.props; | ||
if (props.closable) { | ||
if (e.keyCode === KeyCode.ESC) { | ||
this.props.onRequestClose(); | ||
} | ||
} | ||
// keep focus inside dialog | ||
if (props.visible) { | ||
if (e.keyCode === KeyCode.TAB) { | ||
var activeElement = document.activeElement; | ||
var dialogRoot = React.findDOMNode(this.refs.dialog); | ||
var sentinel = React.findDOMNode(this.refs.sentinel); | ||
if (e.shiftKey) { | ||
if (activeElement === dialogRoot) { | ||
sentinel.focus(); | ||
} | ||
} else if (activeElement === React.findDOMNode(this.refs.sentinel)) { | ||
dialogRoot.focus(); | ||
} | ||
} | ||
} | ||
}, | ||
handleMaskClick: function handleMaskClick() { | ||
if (this.props.closable) { | ||
this.props.onRequestClose(); | ||
} | ||
React.findDOMNode(this.refs.dialog).focus(); | ||
}, | ||
@@ -135,3 +169,5 @@ | ||
var maskProps = {}; | ||
var maskProps = { | ||
onClick: this.handleMaskClick | ||
}; | ||
var dialogProps = { | ||
@@ -142,8 +178,6 @@ className: [prefixCls, props.className].join(' '), | ||
ref: 'dialog', | ||
style: style | ||
style: style, | ||
onKeyDown: this.handleKeyDown | ||
}; | ||
if (closable) { | ||
maskProps.onClick = props.onRequestClose; | ||
dialogProps.onKeyDown = this.handleKeyDown; | ||
} | ||
if (style.zIndex) { | ||
@@ -180,3 +214,3 @@ maskProps.style = { zIndex: style.zIndex }; | ||
{ className: className.join(' ') }, | ||
props.mask !== false ? React.createElement('div', _extends({}, maskProps, { className: prefixClsFn(prefixCls, 'mask'), ref: 'mask' })) : null, | ||
props.mask ? React.createElement('div', _extends({}, maskProps, { className: prefixClsFn(prefixCls, 'mask'), ref: 'mask' })) : null, | ||
React.createElement( | ||
@@ -195,2 +229,7 @@ 'div', | ||
footer | ||
), | ||
React.createElement( | ||
'div', | ||
{ tabIndex: '0', ref: 'sentinel', style: { width: 0, height: 0, overflow: 'hidden' } }, | ||
'sentinel' | ||
) | ||
@@ -202,2 +241,4 @@ ) | ||
module.exports = Dialog; | ||
module.exports = Dialog; | ||
// empty |
@@ -127,3 +127,3 @@ 'use strict'; | ||
var props = this.props; | ||
var dialogProps = copy(props, ['className', 'closable', 'align', 'title', 'footer', 'animation', 'transitionName', 'maskAnimation', 'maskTransitionName', 'prefixCls', 'style', 'width', 'height', 'zIndex']); | ||
var dialogProps = copy(props, ['className', 'closable', 'align', 'title', 'footer', 'mask', 'animation', 'transitionName', 'maskAnimation', 'maskTransitionName', 'prefixCls', 'style', 'width', 'height', 'zIndex']); | ||
@@ -196,2 +196,3 @@ assign(dialogProps, { | ||
renderToBody: true, | ||
mask: true, | ||
closable: true, | ||
@@ -198,0 +199,0 @@ prefixCls: 'rc-dialog', |
{ | ||
"name": "rc-dialog", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"description": "dialog ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26961
722