This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
[Frontend] Fix faketouch capturing touches on UI. #410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relevant components:
Problem statement:
When you enable the setting
FakeMouseWithTouches
, touches on the UI buttons will no longer work.(Tested on iOS 17 Safari & Chrome and Android 13 Chrome & Firefox.)
This is applicable from version 5.2 up to 5.4 and the master branch.
Screen captures
On Android 13 on the latest Chrome browser:
before.mp4
after.mp4
Solution
The issue is caused by
touch.preventDefault()
in the FakeTouchController script.In
OnTouchStart
I check whether the touch is actually on the video element.In
OnTouchMove
andOnTouchEnd
I added a null check because the existing code can run into an undefinedthis.fakeTouchFinger.id
.This also avoids the
preventDefault
call when it is not needed.The only drawback of this 'fix' is that the focus state of the buttons will not blur when clicking the video, as you can see at the end of the 'after' video.
This could be resolved by entirely removing
touch.prevenDefault()
from theOnTouchEnd
function, but I'm not sure if this might have any unintended side effects.Documentation
N / A
Test Plan and Compatibility
This could theoretically break someone's existing project if they place HTML elements on top of the video element, maybe for some kind of gradient or vignette effect.
However disabling pointer events on those elements should solve any issues.