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

chore(web): fixes implicit-this cases 🔩 #11459

Merged
merged 4 commits into from
May 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ export class InputSequenceSimulator<HoveredItemType> {

// Produces a hacky-but-sufficient implementation of TouchList for our purposes
// in environments that avoid direct touch-support.
const arrToTouchList = (arr: Touch[]): TouchList => {
const arrToTouchList = (arr: Touch[]): TouchList & { _arr: Touch[]} => {
return {
//@ts-ignore
_arr: arr, // Obviously, this isn't a standard member of TouchList.
length: arr.length,
item: function(i: number) { return this._arr[i]; }
Expand Down
4 changes: 2 additions & 2 deletions web/src/app/browser/src/context/focusAssistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ export class FocusAssistant extends EventEmitter<EventMap> {
setFocusTimer(): void {
this.focusing=true;

this.focusTimer = window.setTimeout(function() {
this.focusTimer = window.setTimeout(() => {
this.focusing=false;
}.bind(this), 50)
}, 50)
}
}
23 changes: 16 additions & 7 deletions web/src/app/browser/src/languageMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import { KeyboardStub } from "keyman/engine/package-cache";
import KeymanEngine from "./keymanEngine.js";
import * as util from "./utils/index.js";

interface KeyboardTag {
/**
* Keyboard name
*/
kn: string;

/**
* Keyboard language code
*/
kc: string;
}

// Used by 'native'-mode KMW only - the Android and iOS embedding apps implement their own menus.
export class LanguageMenu {
private readonly keyman: KeymanEngine;
Expand Down Expand Up @@ -408,7 +420,7 @@ export class LanguageMenu {
* @param {Object} kb element being added and styled
* @param {boolean} unique is this the only keyboard for the language?
*/
addKeyboard(kbd, kb, unique: boolean) {
addKeyboard(kbd: KeyboardStub, kb: HTMLParagraphElement & KeyboardTag, unique: boolean) {
kb.kn=kbd['KI']; // InternalName;
kb.kc=kbd['KLC']; // LanguageCode;
kb.innerHTML=unique?kbd['KL']:kbd['KN'].replace(' Keyboard',''); // Name
Expand Down Expand Up @@ -465,7 +477,7 @@ export class LanguageMenu {
}

// Touchstart (or mspointerdown) event highlights the touched list item
const touchStart=function(e) {
const touchStart = function(this: HTMLElement & KeyboardTag, e: TouchEvent) {
e.stopPropagation();
if(this.className.indexOf('selected') <= 0) {
this.className=this.className+' selected';
Expand All @@ -478,7 +490,7 @@ export class LanguageMenu {

//TODO: Still drags Android background sometimes (not consistently)
// Touchmove drags the list and prevents release from selecting the language
const touchMove=function(e: TouchEvent) {
const touchMove=function(this: HTMLElement & KeyboardTag, e: TouchEvent) {
e.stopImmediatePropagation();
var scroller=<HTMLElement>languageMenu.lgList.childNodes[0],
yMax=scroller.scrollHeight-scroller.offsetHeight,
Expand Down Expand Up @@ -522,7 +534,7 @@ export class LanguageMenu {
};

// Touch release (click) event selects touched list item
const touchEnd=function(e: TouchEvent) {
const touchEnd=function(this: HTMLElement & KeyboardTag, e: TouchEvent) {
if(typeof(e.stopImmediatePropagation) != 'undefined') {
e.stopImmediatePropagation();
} else {
Expand All @@ -548,11 +560,8 @@ export class LanguageMenu {
unlockBodyScroll();
}

kb.onmspointerdown=touchStart;
kb.addEventListener('touchstart',touchStart,false);
kb.onmspointermove=touchMove;
kb.addEventListener('touchmove',touchMove,false);
kb.onmspointerout=touchEnd;
kb.addEventListener('touchend',touchEnd,false);
kb.addEventListener('touchcancel',touchCancel,false);
}
Expand Down
1 change: 0 additions & 1 deletion web/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

// TODO: These override ../tsconfig.base.json settings, and so should be removed if possible,
// but existing code in web/ breaks some of these settinsg
"noImplicitThis": false,
"noImplicitReturns": false,
"noImplicitAny": false,
"strictFunctionTypes": false,
Expand Down
Loading