Skip to content

Commit

Permalink
always call exitPointerLock (#6458)
Browse files Browse the repository at this point in the history
**Problem:**
If a scrubbing using the new pointer lock based scrubber control was
quick enough, we would often not release the pointer on mouse up –
instead leaving you with a hidden cursor until you press Esc.

**Fix:**
Turns out, `document.pointerLockElement` is still null for a few moments
after getting pointer lock, and our code calling
`document.exitPointerLock` checks if the pointer lock element is the
same as the current control's target.

By simply removing the check, we call exitPointerLock() all of the time,
making it not brittle anymore.
  • Loading branch information
balazsbajorics authored and liady committed Dec 13, 2024
1 parent cb088bc commit ec001f6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions editor/src/uuiui/inputs/number-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ export const NumberInput = React.memo<NumberInputProps>(

const cancelPointerLock = React.useCallback(
(revertChanges: 'revert-nothing' | 'revert-changes') => {
if (document.pointerLockElement === pointerOriginRef.current) {
document.exitPointerLock()
}
document.exitPointerLock()
if (
revertChanges === 'revert-changes' &&
onSubmitValue != null &&
Expand Down

0 comments on commit ec001f6

Please sign in to comment.