TF-3911 Remove window event listeners to prevent memory leaks in Email View
This commit is contained in:
@@ -286,7 +286,13 @@ class HtmlInteraction {
|
||||
}, {
|
||||
passive: false,
|
||||
});
|
||||
window.addEventListener('keydown', function(e) {
|
||||
window.addEventListener('keydown', disableZoomControl);
|
||||
|
||||
window.addEventListener('pagehide', (event) => {
|
||||
window.removeEventListener('keydown', disableZoomControl);
|
||||
});
|
||||
|
||||
function disableZoomControl(event) {
|
||||
if (event.metaKey || event.ctrlKey) {
|
||||
switch (event.key) {
|
||||
case '=':
|
||||
@@ -295,7 +301,7 @@ class HtmlInteraction {
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
''';
|
||||
|
||||
@@ -381,7 +387,13 @@ class HtmlInteraction {
|
||||
|
||||
static String scriptHandleIframeKeyboardListener(String viewId) => '''
|
||||
<script type="text/javascript">
|
||||
window.addEventListener('keydown', function (event) {
|
||||
window.addEventListener('keydown', handleIframeKeydown);
|
||||
|
||||
window.addEventListener('pagehide', (event) => {
|
||||
window.removeEventListener('keydown', handleIframeKeydown);
|
||||
});
|
||||
|
||||
function handleIframeKeydown(event) {
|
||||
const payload = {
|
||||
view: '$viewId',
|
||||
type: 'toDart: iframeKeydown',
|
||||
@@ -390,7 +402,7 @@ class HtmlInteraction {
|
||||
shift: event.shiftKey
|
||||
};
|
||||
window.parent.postMessage(JSON.stringify(payload), "*");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
''';
|
||||
}
|
||||
Reference in New Issue
Block a user