Skip to content

Commit

Permalink
Don't update the DOM if the toggle has been removed
Browse files Browse the repository at this point in the history
Currently, if the toggle causes the element to be removed from the DOM, the code that updates the DOM fails with `TypeError: Cannot read property 'querySelector' of null`
  • Loading branch information
mweidner037 committed Dec 13, 2024
1 parent 0b8ecca commit b22dab3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addon/components/x-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export default class XToggle extends Component {

@action
toggleSwitch(value) {
// Prevent re-renders when the element is cleaning up (which cause errors).
if (this.isDestroyed || this.isDestroying) return

Check failure on line 58 in addon/components/x-toggle.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`

Check failure on line 58 in addon/components/x-toggle.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`

let onToggle = this.args.onToggle;
let disabled = this.disabled;

Expand Down

0 comments on commit b22dab3

Please sign in to comment.