mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-04 20:13:11 +08:00
fix(tooltips): comp. w/ tooltip must be conditionally rendered
Also update tooltips to support functional components.
This commit is contained in:
parent
020cc06b36
commit
4744caab77
2 changed files with 12 additions and 14 deletions
|
@ -104,11 +104,14 @@ class TipPopoverContents extends React.Component {
|
|||
export default function HasTutorialTip(ComposedComponent, TipConfig) {
|
||||
const TipKey = ComposedComponent.displayName;
|
||||
|
||||
if (!TipKey) {
|
||||
throw new Error("To use the HasTutorialTip decorator, your component must have a displayName.");
|
||||
}
|
||||
if (TipsStore.hasSeenTip(TipKey)) {
|
||||
return ComposedComponent;
|
||||
}
|
||||
|
||||
return class extends ComposedComponent {
|
||||
return class extends React.Component {
|
||||
static displayName = ComposedComponent.displayName;
|
||||
|
||||
constructor(props) {
|
||||
|
@ -118,10 +121,6 @@ export default function HasTutorialTip(ComposedComponent, TipConfig) {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (super.componentDidMount) {
|
||||
super.componentDidMount();
|
||||
}
|
||||
|
||||
TipsStore.mountedTip(TipKey);
|
||||
|
||||
this._unlisteners = [
|
||||
|
@ -153,20 +152,13 @@ export default function HasTutorialTip(ComposedComponent, TipConfig) {
|
|||
this._onTooltipStateChanged();
|
||||
}
|
||||
|
||||
componentDidUpdate(...args) {
|
||||
if (super.componentDidUpdate) {
|
||||
super.componentDidUpdate(...args);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
if (this.state.visible) {
|
||||
this._onRecomputeTooltipPosition();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (super.componentWillUnmount) {
|
||||
super.componentWillUnmount();
|
||||
}
|
||||
|
||||
this._unlisteners.forEach((unlisten) => unlisten())
|
||||
this._disposables.forEach((disposable) => disposable.dispose())
|
||||
|
||||
|
@ -261,5 +253,11 @@ export default function HasTutorialTip(ComposedComponent, TipConfig) {
|
|||
}
|
||||
attempt();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ComposedComponent {...this.props} />
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
src/pro
2
src/pro
|
@ -1 +1 @@
|
|||
Subproject commit a35be90c3c316c2467bb577dade5f6738799f84d
|
||||
Subproject commit 88f3dc53e3fca98ac91ff4c6da6e7ff6e5493902
|
Loading…
Reference in a new issue