MOBILE-4065 chore: Change to strict comparison in event key names
parent
c1370250f5
commit
51420ada52
|
@ -29,19 +29,19 @@ export class CoreAriaRoleTab<T = unknown> {
|
||||||
* @param e Event.
|
* @param e Event.
|
||||||
*/
|
*/
|
||||||
keyDown(tabFindIndex: string, e: KeyboardEvent): void {
|
keyDown(tabFindIndex: string, e: KeyboardEvent): void {
|
||||||
if (e.key == ' ' ||
|
if (e.key === ' ' ||
|
||||||
e.key == 'Enter' ||
|
e.key === 'Enter' ||
|
||||||
e.key == 'Home' ||
|
e.key === 'Home' ||
|
||||||
e.key == 'End' ||
|
e.key === 'End' ||
|
||||||
(this.isHorizontal() && (e.key == 'ArrowRight' || e.key == 'ArrowLeft')) ||
|
(this.isHorizontal() && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) ||
|
||||||
(!this.isHorizontal() && (e.key == 'ArrowUp' ||e.key == 'ArrowDown'))
|
(!this.isHorizontal() && (e.key === 'ArrowUp' ||e.key === 'ArrowDown'))
|
||||||
) {
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key == ' ' || e.key == 'Enter') {
|
if (e.key === ' ' || e.key === 'Enter') {
|
||||||
this.selectTabCandidate = tabFindIndex;
|
this.selectTabCandidate = tabFindIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ export class CoreAriaRoleTab<T = unknown> {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
|
|
||||||
if (e.key == ' ' || e.key == 'Enter') {
|
if (e.key === ' ' || e.key === 'Enter') {
|
||||||
if (this.selectTabCandidate === tabFindIndex) {
|
if (this.selectTabCandidate === tabFindIndex) {
|
||||||
this.selectTab(tabFindIndex, e);
|
this.selectTab(tabFindIndex, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
|
||||||
* @param event The mouse event.
|
* @param event The mouse event.
|
||||||
*/
|
*/
|
||||||
doNotBlur(event: Event): void {
|
doNotBlur(event: Event): void {
|
||||||
if (event.type == 'keydown' && !this.isValidKeyboardKey(<KeyboardEvent>event)) {
|
if (event.type === 'keydown' && !this.isValidKeyboardKey(<KeyboardEvent>event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
|
||||||
* @returns Wether space or enter have been pressed.
|
* @returns Wether space or enter have been pressed.
|
||||||
*/
|
*/
|
||||||
protected isValidKeyboardKey(event: KeyboardEvent): boolean {
|
protected isValidKeyboardKey(event: KeyboardEvent): boolean {
|
||||||
return event.key == ' ' || event.key == 'Enter';
|
return event.key === ' ' || event.key === 'Enter';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,7 +391,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
|
|
||||||
this.stopBubble(event);
|
this.stopBubble(event);
|
||||||
|
|
||||||
const move = event.key == 'ArrowLeft' ? -1 : +1;
|
const move = event.key === 'ArrowLeft' ? -1 : +1;
|
||||||
const cursor = this.getCurrentCursorPosition(this.editorElement);
|
const cursor = this.getCurrentCursorPosition(this.editorElement);
|
||||||
|
|
||||||
this.setCurrentCursorPosition(this.editorElement, cursor + move);
|
this.setCurrentCursorPosition(this.editorElement, cursor + move);
|
||||||
|
@ -754,7 +754,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
* @returns Wether space or enter have been pressed.
|
* @returns Wether space or enter have been pressed.
|
||||||
*/
|
*/
|
||||||
protected isValidKeyboardKey(event: KeyboardEvent): boolean {
|
protected isValidKeyboardKey(event: KeyboardEvent): boolean {
|
||||||
return event.key == ' ' || event.key == 'Enter';
|
return event.key === ' ' || event.key === 'Enter';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -353,7 +353,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
|
||||||
* @param e Event.
|
* @param e Event.
|
||||||
*/
|
*/
|
||||||
keyDown(e: KeyboardEvent): void {
|
keyDown(e: KeyboardEvent): void {
|
||||||
if (e.key == 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
|
||||||
* @param e Event.
|
* @param e Event.
|
||||||
*/
|
*/
|
||||||
keyUp(e: KeyboardEvent): void {
|
keyUp(e: KeyboardEvent): void {
|
||||||
if (e.key == 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
this.cancel(e);
|
this.cancel(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,7 +519,7 @@ export class CoreDom {
|
||||||
element.addEventListener('click', (event) => callback(event));
|
element.addEventListener('click', (event) => callback(event));
|
||||||
|
|
||||||
element.addEventListener('keydown', (event) => {
|
element.addEventListener('keydown', (event) => {
|
||||||
if ((event.key == ' ' || event.key == 'Enter')) {
|
if (event.key === ' ' || event.key === 'Enter') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue