Skip to content
This repository was archived by the owner on May 23, 2018. It is now read-only.

Commit c7ac405

Browse files
committed
feat: onClick doesn't override main click handler [close #4]
1 parent 3304fa7 commit c7ac405

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/link-factory.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ function linkFactory(router) {
4040
},
4141

4242
clickHandler(evt) {
43+
if (this.props.onClick) {
44+
this.props.onClick(evt);
45+
46+
if (evt.defaultPrevented) {
47+
return;
48+
}
49+
}
50+
4351
let comboKey = event.metaKey || event.altKey || event.ctrlKey || event.shiftKey;
4452

4553
if (evt.button === 0 && !comboKey) {
@@ -70,7 +78,7 @@ function linkFactory(router) {
7078
let href = router.buildUrl(props.routeName, props.routeParams)
7179
let className = (props.className ? props.className.split(' ') : [])
7280
.concat(active ? [props.activeClassName] : []).join(' ')
73-
let onClick = props.onClick || this.clickHandler
81+
let onClick = this.clickHandler
7482

7583
return React.createElement('a', {href, className, onClick}, props.children)
7684
}

0 commit comments

Comments
 (0)