From a432918e209559506405e6bef7f582a6629ee71b Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Thu, 14 Nov 2024 16:52:43 +0100 Subject: [PATCH] Remove inspector component to properly unregister keydown listener when the inspector is loaded via a script tag otherwise the listener will be registered twice and we can't toggle the inspector from viewer mode with the shortcut. (#774) --- src/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.js b/src/index.js index d7cd50b3..73b8dbc0 100644 --- a/src/index.js +++ b/src/index.js @@ -168,6 +168,9 @@ Inspector.prototype = { }, initEvents: function () { + // Remove inspector component to properly unregister keydown listener when the inspector is loaded via a script tag, + // otherwise the listener will be registered twice and we can't toggle the inspector from viewer mode with the shortcut. + this.sceneEl.removeAttribute('inspector'); window.addEventListener('keydown', (evt) => { // Alt + Ctrl + i: Shorcut to toggle the inspector const shortcutPressed =