Fix intermittent crash due to invalid iframe reference when hot reloading
This commit is contained in:
parent
d368e54d17
commit
f88ef064b1
|
@ -104,8 +104,10 @@
|
||||||
|
|
||||||
// remove all iframe event listeners on component destroy
|
// remove all iframe event listeners on component destroy
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
if (iframe.contentWindow) {
|
||||||
iframe.contentWindow.removeEventListener("bb-event", handleBudibaseEvent)
|
iframe.contentWindow.removeEventListener("bb-event", handleBudibaseEvent)
|
||||||
iframe.contentWindow.removeEventListener("keydown", handleKeydownEvent)
|
iframe.contentWindow.removeEventListener("keydown", handleKeydownEvent)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleBudibaseEvent = event => {
|
const handleBudibaseEvent = event => {
|
||||||
|
@ -123,17 +125,21 @@
|
||||||
} else {
|
} else {
|
||||||
console.warning(`Client sent unknown event type: ${type}`)
|
console.warning(`Client sent unknown event type: ${type}`)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleKeydownEvent = event => {
|
const handleKeydownEvent = event => {
|
||||||
if ((event.key === "Delete" || event.key === "Backspace") &&
|
if (
|
||||||
|
(event.key === "Delete" || event.key === "Backspace") &&
|
||||||
selectedComponentId &&
|
selectedComponentId &&
|
||||||
['input', 'textarea'].indexOf(iframe.contentWindow.document.activeElement?.tagName.toLowerCase()) === -1) {
|
["input", "textarea"].indexOf(
|
||||||
confirmDeleteComponent(selectedComponentId);
|
iframe.contentWindow.document.activeElement?.tagName.toLowerCase()
|
||||||
|
) === -1
|
||||||
|
) {
|
||||||
|
confirmDeleteComponent(selectedComponentId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmDeleteComponent = (componentId) => {
|
const confirmDeleteComponent = componentId => {
|
||||||
idToDelete = componentId
|
idToDelete = componentId
|
||||||
confirmDeleteDialog.show()
|
confirmDeleteDialog.show()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue