From 6863fa37640a179ed314f28afeee267ead80ffae Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Fri, 4 Feb 2022 14:46:57 +0100 Subject: [PATCH] Fix game unfocusable after clicking on iframe --- front/src/Phaser/Game/Game.ts | 9 --------- front/src/Phaser/UserInput/UserInputManager.ts | 5 +++++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/front/src/Phaser/Game/Game.ts b/front/src/Phaser/Game/Game.ts index 865026f7..783f2348 100644 --- a/front/src/Phaser/Game/Game.ts +++ b/front/src/Phaser/Game/Game.ts @@ -26,15 +26,6 @@ export class Game extends Phaser.Game { } } }); - - /*window.addEventListener('resize', (event) => { - // Let's trigger the onResize method of any active scene that is a ResizableScene - for (const scene of this.scene.getScenes(true)) { - if (scene instanceof ResizableScene) { - scene.onResize(event); - } - } - });*/ } public step(time: number, delta: number) { diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index ffa67c3a..112ab0e5 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -255,6 +255,11 @@ export class UserInputManager { (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => { this.joystick?.hide(); this.userInputHandler.handlePointerUpEvent(pointer, gameObjects); + + // Disable focus on iframe (need by Firefox) + if (pointer.downElement.nodeName === "CANVAS" && document.activeElement instanceof HTMLIFrameElement) { + document.activeElement.blur(); + } } );