From 1c3d76c2dc5a5cda670f33a98efc77b1c9a098b8 Mon Sep 17 00:00:00 2001 From: Ben Biggs Date: Mon, 30 Sep 2019 12:50:27 -0500 Subject: [PATCH] fix(Coachmark): fire rerender if initially open --- react/src/lib/Coachmark/index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/react/src/lib/Coachmark/index.js b/react/src/lib/Coachmark/index.js index 80d5ad95ba..86d990050c 100644 --- a/react/src/lib/Coachmark/index.js +++ b/react/src/lib/Coachmark/index.js @@ -9,12 +9,11 @@ class Coachmark extends React.Component { static displayName = 'Coachmark'; state = { - isOpen: false + isOpen: this.props.isOpen || false }; componentDidMount() { - this.props.isOpen && - this.delayedShow(); + this.props.isOpen && this.forceUpdate(); } componentDidUpdate(prevProps) { @@ -73,8 +72,8 @@ class Coachmark extends React.Component { }; handleClose = () => { - this.setState(() => ({ - isOpen: false + this.setState(() => ({ + isOpen: false }), this.delayedHide() ); @@ -105,7 +104,7 @@ class Coachmark extends React.Component { 'showDelay' ]); - const anchorWithRef = ( + const anchorWithRef = () => ( children && React.cloneElement(children, { ref: ele => this.anchorRef = ele, ...otherProps @@ -128,7 +127,7 @@ class Coachmark extends React.Component { return ( - {anchorWithRef} + {anchorWithRef()} { isOpen &&