Merge pull request #1755 from pablolmiranda/fixes-tooltip-for-button

Tooltip for disabled button
old
Rubén Moya 2018-01-23 18:17:39 +01:00 committed by GitHub
commit 2a6b62cd81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -101,6 +101,10 @@ const factory = (ripple, FontIcon) => {
const element = href ? 'a' : 'button';
const level = this.getLevel();
const shape = this.getShape();
const mouseEvents = {
onMouseUp: this.handleMouseUp,
onMouseLeave: this.handleMouseLeave,
};
const classes = classnames(theme.button, [theme[shape]], {
[theme[level]]: neutral,
@ -110,21 +114,24 @@ const factory = (ripple, FontIcon) => {
const props = {
...others,
...mouseEvents,
href,
ref: (node) => { this.buttonNode = node; },
className: classes,
disabled: this.props.disabled,
onMouseUp: this.handleMouseUp,
onMouseLeave: this.handleMouseLeave,
type: !href ? type : null,
'data-react-toolbox': 'button',
};
return React.createElement(element, props,
const buttonElement = React.createElement(element, props,
icon ? <FontIcon className={theme.icon} value={icon} /> : null,
label,
children,
);
return others.onMouseEnter && this.props.disabled
? <span {...mouseEvents}>{buttonElement}</span>
: buttonElement;
}
}

View File

@ -20,6 +20,7 @@ const TooltipTest = () => (
<section>
<h5>Tooltip</h5>
<p>Give information on :hover</p>
<TooltipButton label="Bookmark" icon="bookmark" raised primary disabled={true} tooltip="Bookmark Tooltip" tooltipDelay={1000} />
<TooltipButton label="Bookmark" icon="bookmark" raised primary tooltip="Bookmark Tooltip" tooltipDelay={1000} />
<TooltipButton icon="add" floating accent tooltip="Floating Tooltip" />
<TooltipButton icon="add" floating disabled tooltip="Floating can not be shown" />