Skip to content

Commit

Permalink
Clear save timeout handler when unmounting the editor. Fix #208 (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas authored Apr 14, 2021
1 parent 4b7fbc1 commit 5c9a53d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions lib/components/DraftailEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ class DraftailEditor extends Component<Props, State> {

componentWillUnmount() {
this.copySource.unregister();

window.clearTimeout(this.updateTimeout);
}

/* :: onFocus: () => void; */
Expand Down
2 changes: 2 additions & 0 deletions lib/components/DraftailEditor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,11 @@ describe("DraftailEditor", () => {
const wrapper = mount(<DraftailEditor />);
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", () => {
Expand Down

0 comments on commit 5c9a53d

Please sign in to comment.