Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11891 Enhanced Input Mode Detection for Hybrid Devices #11998

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions kolibri/core/assets/src/utils/browserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ export const isTouchDevice =
'ontouchstart' in window ||
window.navigator?.maxTouchPoints > 0 ||
window.navigator?.msMaxTouchPoints > 0;

function handlePointerDown(event) {
if (event.pointerType === 'mouse') {
localStorage.setItem('mouseUsed', 'true');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then in here we can do this and:

isMouseUsed = true;

isMouseUsed = true;
window.removeEventListener('pointerdown', handlePointerDown);
}
}

window.addEventListener('pointerdown', handlePointerDown);

export let isMouseUsed = localStorage.getItem('mouseUsed') === 'true';
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
import client from 'kolibri.client';
import urls from 'kolibri.urls';
import responsiveWindowMixin from 'kolibri.coreVue.mixins.responsiveWindowMixin';
import { isTouchDevice } from 'kolibri.utils.browserInfo';
import { isTouchDevice, isMouseUsed } from 'kolibri.utils.browserInfo';
import scriptLoader from 'kolibri-common/utils/scriptLoader';
import perseus from '../../dist/perseus';
import icu from '../KAGlobals/icu';
Expand Down Expand Up @@ -144,7 +144,7 @@
return this.windowBreakpoint < 3;
},
usesTouch() {
return isTouchDevice;
return isTouchDevice && !isMouseUsed;
},
itemRenderData() {
return {
Expand Down
Loading