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

Commit

Permalink
feat: onClick doesn't override main click handler [close #4]
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtech-dobes committed Sep 18, 2015
1 parent 3304fa7 commit c7ac405
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/link-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ function linkFactory(router) {
},

clickHandler(evt) {
if (this.props.onClick) {
this.props.onClick(evt);

if (evt.defaultPrevented) {
return;
}
}

let comboKey = event.metaKey || event.altKey || event.ctrlKey || event.shiftKey;

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

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

0 comments on commit c7ac405

Please sign in to comment.