Check if event is cancelable before preventDefault (#54)

This recovers the initial wanted behavior of opening the post mention preview dropdown instead of directly going to the post on touchscreens.
This commit is contained in:
Sami Mazouz 2020-10-29 23:33:26 +01:00 committed by GitHub
parent 2b6b7ed26e
commit 367a1b2329

View File

@ -103,7 +103,14 @@ export default function addPostMentionPreviews() {
}
};
$this.on('touchstart', e => e.preventDefault());
// On a touch (mobile) device we cannot hover the link to reveal the preview.
// Instead we cancel the navigation so that a click reveals the preview.
// Users can then click on the preview to go to the post if desired.
$this.on('touchend', e => {
if (e.cancelable) {
e.preventDefault();
}
});
$this.add($preview).hover(
() => {