Skip to content

Commit 7e6a27a

Browse files
committed
fixup! fix(image-editor): open newly created image when closing the image editor
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
1 parent 72ee207 commit 7e6a27a

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/components/ImageEditor.vue

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default {
3939
data() {
4040
return {
4141
imageEditor: null,
42-
observer: null,
4342
}
4443
},
4544
@@ -134,31 +133,14 @@ export default {
134133
)
135134
this.imageEditor.render()
136135
window.addEventListener('keydown', this.handleKeydown, true)
137-
138-
this.observer = new MutationObserver((mutations) => {
139-
mutations.forEach((mutation) => {
140-
if (mutation.type === 'childList') {
141-
mutation.addedNodes.forEach((node) => {
142-
if (node.classList.contains('FIE_root') || node.classList.contains('SfxModal-Wrapper')) {
143-
emit('viewer:trapElements:changed', node)
144-
}
145-
})
146-
}
147-
})
148-
})
149-
// using body instead of the editor ref because save modal is not mounted in editor
150-
this.observer.observe(document.body, {
151-
childList: true,
152-
subtree: true,
153-
})
136+
window.addEventListener('DOMNodeInserted', this.handleSfxModal)
154137
155138
},
156139
157140
beforeDestroy() {
158141
if (this.imageEditor) {
159142
this.imageEditor.terminate()
160143
}
161-
this.observer.disconnect()
162144
window.removeEventListener('keydown', this.handleKeydown, true)
163145
},
164146
@@ -313,6 +295,17 @@ export default {
313295
}
314296
},
315297
298+
/**
299+
* Watch out for Modal inject in document root
300+
* That way we can adjust the focusTrap
301+
*
302+
* @param {Event} event Dom insertion event
303+
*/
304+
handleSfxModal(event) {
305+
if (event.target?.classList && event.target.classList.contains('SfxModal-Wrapper')) {
306+
emit('viewer:trapElements:changed', event.target)
307+
}
308+
},
316309
},
317310
}
318311
</script>

0 commit comments

Comments
 (0)