Skip to content

Commit

Permalink
fix(Coachmark): fire rerender if initially open
Browse files Browse the repository at this point in the history
  • Loading branch information
bfbiggs authored and pauljeter committed Sep 30, 2019
1 parent c62248e commit 1c3d76c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions react/src/lib/Coachmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -73,8 +72,8 @@ class Coachmark extends React.Component {
};

handleClose = () => {
this.setState(() => ({
isOpen: false
this.setState(() => ({
isOpen: false
}),
this.delayedHide()
);
Expand Down Expand Up @@ -105,7 +104,7 @@ class Coachmark extends React.Component {
'showDelay'
]);

const anchorWithRef = (
const anchorWithRef = () => (
children && React.cloneElement(children, {
ref: ele => this.anchorRef = ele,
...otherProps
Expand All @@ -128,7 +127,7 @@ class Coachmark extends React.Component {

return (
<React.Fragment>
{anchorWithRef}
{anchorWithRef()}
{
isOpen &&
<EventOverlay
Expand Down

0 comments on commit 1c3d76c

Please sign in to comment.