diff --git a/packages/component-faraday-ui/src/AutosaveIndicator.js b/packages/component-faraday-ui/src/AutosaveIndicator.js index 57f5d59558fdc9507ba7a4cf3990f63dbf5cfdc1..10335b7e8305dfd6750c67a2195bfbd36a4b7544 100644 --- a/packages/component-faraday-ui/src/AutosaveIndicator.js +++ b/packages/component-faraday-ui/src/AutosaveIndicator.js @@ -15,14 +15,22 @@ class AutosaveIndicator extends Component { this.timer = null } + componentDidMount() { + this.setTimer() + } + componentWillReceiveProps({ autosave: nextAutosave }) { const { autosave, toggleVisible } = this.props - if (autosave && !isEqual(autosave, nextAutosave)) { + if (!isEqual(autosave, nextAutosave)) { toggleVisible() this.setTimer() } } + componentWillUnmount() { + clearTimeout(this.timer) + } + setTimer = () => { const { toggleVisible, delay = 2000 } = this.props if (this.timer) {