diff --git a/CHANGELOG.md b/CHANGELOG.md index 67b9dc4c..19929907 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ ### Fixed - Fix empty buttons appearing when providing custom formats without a defined label or icon. [#442](https://github.com/springload/draftail/pull/442) +- Clear save timeout handler when unmounting the editor. [#208](https://github.com/springload/draftail/issues/208), [#443](https://github.com/springload/draftail/pull/443) ## [[v1.3.0]](https://github.com/springload/draftail/releases/tag/v1.3.0) diff --git a/lib/components/DraftailEditor.js b/lib/components/DraftailEditor.js index 51282cbd..8ebbe3f7 100644 --- a/lib/components/DraftailEditor.js +++ b/lib/components/DraftailEditor.js @@ -329,6 +329,8 @@ class DraftailEditor extends Component { componentWillUnmount() { this.copySource.unregister(); + + window.clearTimeout(this.updateTimeout); } /* :: onFocus: () => void; */ diff --git a/lib/components/DraftailEditor.test.js b/lib/components/DraftailEditor.test.js index cea7dbf0..309c2c3f 100644 --- a/lib/components/DraftailEditor.test.js +++ b/lib/components/DraftailEditor.test.js @@ -359,9 +359,11 @@ describe("DraftailEditor", () => { const wrapper = mount(); const { copySource } = wrapper.instance(); jest.spyOn(copySource, "unregister"); + jest.spyOn(window, "clearTimeout"); expect(copySource).not.toBeNull(); wrapper.unmount(); expect(copySource.unregister).toHaveBeenCalled(); + expect(window.clearTimeout).toHaveBeenCalled(); }); describe("onChange", () => {