Merge pull request #273 from kagux/feature/event-propagation

Feature/event propagation
old
Javi Velasco 2016-01-22 22:02:35 +01:00
commit 6831912903
6 changed files with 17 additions and 20 deletions

View File

@ -36,14 +36,14 @@ class Button extends React.Component {
raised: false
};
handleMouseUp = () => {
handleMouseUp = (event) => {
this.refs.button.blur();
if (this.props.onMouseUp) this.props.onMouseUp();
if (this.props.onMouseUp) this.props.onMouseUp(event);
};
handleMouseLeave = () => {
handleMouseLeave = (event) => {
this.refs.button.blur();
if (this.props.onMouseLeave) this.props.onMouseLeave();
if (this.props.onMouseLeave) this.props.onMouseLeave(event);
};
render () {

View File

@ -9,10 +9,7 @@ class Checkbox extends React.Component {
className: React.PropTypes.string,
disabled: React.PropTypes.bool,
label: React.PropTypes.any,
name: React.PropTypes.string,
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onFocus: React.PropTypes.func
onChange: React.PropTypes.func
};
static defaultProps = {

View File

@ -35,12 +35,12 @@ class Dropdown extends React.Component {
const client = event.target.getBoundingClientRect();
const screen_height = window.innerHeight || document.documentElement.offsetHeight;
const up = this.props.auto ? client.top > ((screen_height / 2) + client.height) : false;
if (this.props.onFocus) this.props.onFocus();
if (this.props.onFocus) this.props.onFocus(event);
this.setState({active: true, up});
};
handleSelect = (item, event) => {
if (this.props.onBlur) this.props.onBlur();
if (this.props.onBlur) this.props.onBlur(event);
if (!this.props.disabled && this.props.onChange) {
this.props.onChange(item, event);
this.setState({active: false});

View File

@ -28,9 +28,9 @@ class IconMenu extends React.Component {
selectable: false
};
handleButtonClick = () => {
handleButtonClick = (event) => {
this.refs.menu.show();
if (this.props.onClick) this.props.onClick();
if (this.props.onClick) this.props.onClick(event);
};
render () {

View File

@ -26,9 +26,9 @@ class TabHeader extends React.Component {
}
}
handleClick = () => {
handleClick = (event) => {
if (!this.props.disabled && this.props.onClick) {
this.props.onClick();
this.props.onClick(event);
}
};

View File

@ -24,22 +24,22 @@ const Tooltip = (ComposedComponent) => class extends React.Component {
active: false
};
handleMouseEnter = () => {
handleMouseEnter = (event) => {
if (this.timeout) clearTimeout(this.timeout);
this.timeout = setTimeout(() =>this.setState({active: true}), this.props.tooltipDelay);
if (this.props.onMouseEnter) this.props.onMouseEnter();
if (this.props.onMouseEnter) this.props.onMouseEnter(event);
};
handleMouseLeave = () => {
handleMouseLeave = (event) => {
if (this.timeout) clearTimeout(this.timeout);
if (this.state.active) this.setState({active: false});
if (this.props.onMouseLeave) this.props.onMouseLeave();
if (this.props.onMouseLeave) this.props.onMouseLeave(event);
};
handleClick = () => {
handleClick = (event) => {
if (this.timeout) clearTimeout(this.timeout);
if (this.props.tooltipHideOnClick) this.setState({active: false});
if (this.props.onClick) this.props.onClick();
if (this.props.onClick) this.props.onClick(event);
};
render () {