Skip to content

Commit 1b1bdea

Browse files
committed
Added ability to change event propagation mode from default "bubble" to "capture"
1 parent f4f95ce commit 1b1bdea

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,16 @@ class ReactTooltip extends Component {
195195
* Used in customer event
196196
*/
197197
checkStatus (e) {
198-
e.stopPropagation()
198+
if (this.props.eventPropagationMode === 'bubble') {
199+
e.stopPropagation()
200+
}
199201
if (this.state.show && e.currentTarget.getAttribute('currentItem') === 'true') {
200202
this.hideTooltip(e)
201203
} else {
202204
e.currentTarget.setAttribute('currentItem', 'true')
203205
/* when click other place, the tooltip should be removed */
204206
window.removeEventListener('click', this.bindClickListener)
205-
window.addEventListener('click', this.bindClickListener, false)
207+
window.addEventListener('click', this.bindClickListener, this.props.eventPropagationMode === 'capture')
206208

207209
this.showTooltip(e)
208210
this.setUntargetItems(e.currentTarget)
@@ -635,7 +637,12 @@ ReactTooltip.propTypes = {
635637
delayHide: PropTypes.number,
636638
delayShow: PropTypes.number,
637639
event: PropTypes.any,
638-
watchWindow: PropTypes.bool
640+
watchWindow: PropTypes.bool,
641+
eventPropagationMode: PropTypes.oneOf(['bubble', 'capture'])
642+
}
643+
644+
ReactTooltip.defaultProps = {
645+
eventPropagationMode: 'bubble'
639646
}
640647

641648
/* export default not fit for standalone, it will exports {default:...} */

0 commit comments

Comments
 (0)