[英]Adding tooltip to disabled Dropdown.Toggle
If Dropdown.Toggle
is not disabled tooltip works. 如果未禁用
Dropdown.Toggle
则工具提示会起作用。 When Dropdown.Toggle
has the class 当
Dropdown.Toggle
具有类时
.disabled {
pointer-events: none;
}.
Tooltip does not work. 工具提示不起作用。 I'm using the library:
react-bootstrap
and react-tooltip
. 我正在使用库:
react-bootstrap
和react-tooltip
。
Example: https://stackblitz.com/edit/react-tnh9rr 示例: https : //stackblitz.com/edit/react-tnh9rr
class App extends Component {
constructor() {
super();
this.state = {
disabled: true
};
}
render() {
return (
<Dropdown className = {`${this.state.disabled ? 'disabled' : null}`} onClick={this.checkStatus}>
<Dropdown.Toggle data-tip="hello world" variant="success" id="dropdown-basic">
Change status
<ReactTooltip/>
</Dropdown.Toggle>
<Dropdown.Menu >
<Dropdown.Item>AAAAAAA</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
);
}
}
CSS 的CSS
.disabled {
pointer-events: none;
}
You can directly check the state property( disabled
) when the particular function is called with onClick
event on Dropdown
component. 在
Dropdown
组件上使用onClick
事件调用特定函数时,可以直接检查状态属性( disabled
)。 pointer-events: none
disables all the mouse events and hence we are unable to see the tooltip
as tooltip mostly gets triggered when you hover
it on the button
and since hover
is also a kind of event in mouse no event is triggered . pointer-events: none
会禁用所有鼠标事件,因此,我们无法看到tooltip
因为当您将hover
在button
上时,工具提示通常会被触发,并且由于hover
也是hover
中的一种事件,因此不会触发任何事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.