Skip to content

Commit

Permalink
Merge pull request #11998 from poju3185/detect-keyboard-in-perseus
Browse files Browse the repository at this point in the history
Fix #11891 Enhanced Input Mode Detection for Hybrid Devices
  • Loading branch information
rtibbles authored Mar 22, 2024
2 parents 40373ad + b8aae9f commit b16c589
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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');
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

0 comments on commit b16c589

Please sign in to comment.