matrix-org / matrix-org/thirdroom

When pressing Escape to focus on canvas, pointer lock request gets prematurely rejected

Open
#377 0 comments 0 reactions 0 assignees View on GitHub
bug Frontend
Dominant language
C
Stars
647
Forks
70
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I chat a lot via keyboard. But here's the case where I just have to click something with my mouse, otherwise nothing's gonna work.

I wanted chat to disappear after some typing, for which I pressed Esc button. Look, Pointer Lock API is amazing and all, but it seems like two actions take place when I press the aforementioned button. In the mere milliseconds, I see website getting pointer lock granted, but it gets immediately rejected, like it was toggled back. Cursor visiblity blinks to suggest that. Looks like you request pointer lock, but browser decides to toggle it after a little to none delay.

**Reproduction 1**
1. Press Enter, type something, and press Enter again to send the message.
2. The pointer is seen on overlay. You can select various stuff in this mode.
3. Press Esc to get focus back to canvas.
4. Notice cursor blinking? In the end, you don't actually receive focus to canvas.
5. You are stuck in this mode since p. 2, until you click the canvas with left mouse button.
6. Repeat everything and get annoyed by having to click every time to immerse into environment.

**Reproduction 2**
1. Press Esc to open overlay. Pointer is not locked in this mode.
2. Press Esc again to open a menu.
3. Press Esc one more time to get focus back to canvas.
4. Notice cursor blinking? In the end, you don't actually receive focus to canvas.
5. You are stuck in this mode since p. 2, until you click the canvas with left mouse button.
6. Repeat everything and get annoyed by having to click every time to immerse into environment.

**Expected behavior**
It's pretty much covered in #32 (see "Chat"). I expect to get focus on canvas back after pressing Esc, and have pointer locked to start roaming around the environment. Clicking is not an option - it breaks accessibility to some extent.

**Desktop:**
- Manjaro Linux, v22.0.0
- Browsers: Brave, Firefox
- Main branch, 2d1d7362785817822e508226105bda4280799c3e

**Additional context**
Checked on both Firefox and Brave. Even checked the permissions - although, nothing about pointer/cursor locking is there, so I assume it just should work.

Contributor guide

Open the contributing guide

Research direction

Review the Escape-key handling and canvas pointer-lock entry point, using issue #32's Chat section as context. Reproduce both sequences in Firefox or Brave; done means Escape returns focus to the canvas and leaves the pointer locked without requiring a click.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, threejs, typescript
Domain
accessibility, frontend, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.