cm-chessboard icon indicating copy to clipboard operation
cm-chessboard copied to clipboard

fix promotion on mobile (Chrome) in the case that touchstart events get preventDefaulted

Open FurriousFox opened this issue 2 years ago • 3 comments

the mousedown event doesn't get emitted on mobile, making it impossible to promote, so use pointerdown instead

FurriousFox avatar Oct 16 '23 10:10 FurriousFox

Is this a guess or really tested? I ask, because this script runs on my chess server chessmail.de and is used daily by 3000 users on all devices. https://www.chessmail.de/pages/chess-computer.html

Can you please give me more details on which phone, browser and OS it does not work.

shaack avatar Oct 16 '23 11:10 shaack

It was tested in my own project, though I assumed the issue was more widespread than it really was.

It seems that this change is only needed for projects where .preventDefault() gets called on touchstart events (which is the case for my project) as it seems that on Chrome (I'm not sure about other browsers), the mousedown event doesn't get fired if the touchstart event got preventDefaulted.

FurriousFox avatar Oct 16 '23 11:10 FurriousFox

Yes, now it makes sense. Right, if you use .preventDefault(), the mobile browser will not convert the mousedown into an additional touchstart and we can solve this by using pointerdown. I'll check if your pull request works for me and merge it if it does.

shaack avatar Oct 16 '23 12:10 shaack