Skip to content

Commit

Permalink
[4.x] Prevent events being added to an element that doesn't exist whe…
Browse files Browse the repository at this point in the history
…n in grid table mode (#9130)

Check we have a label to add event to
  • Loading branch information
ryanmitchell authored Dec 11, 2023
1 parent dc83887 commit 3d8eade
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions resources/js/components/fieldtypes/bard/BardFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,12 @@ export default {
this.$store.commit(`publish/${this.storeName}/setFieldSubmitsJson`, this.fieldPathPrefix || this.handle);
this.$nextTick(() => {
document.querySelector(`label[for="${this.fieldId}"]`).addEventListener('click', () => {
this.editor.commands.focus();
});
let el = document.querySelector(`label[for="${this.fieldId}"]`);
if (el) {
el.addEventListener('click', () => {
this.editor.commands.focus();
});
}
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ export default {
mounted() {
this.initToolbarButtons();
document.querySelector(`label[for="${this.fieldId}"]`).addEventListener('click', () => {
this.codemirror.focus();
});
let el = document.querySelector(`label[for="${this.fieldId}"]`);
if (el) {
el.addEventListener('click', () => {
this.codemirror.focus();
});
}
},
methods: {
Expand Down

0 comments on commit 3d8eade

Please sign in to comment.