Skip to content

Commit 4220299

Browse files
committed
MOBILE-4653 chore: Fix long press event
1 parent ba81d76 commit 4220299

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/core/directives/long-press.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
// Based on https://medium.com/madewithply/ionic-4-long-press-gestures-96cf1e44098b
1616

1717
import { Directive, ElementRef, OnInit, OnDestroy, Output, EventEmitter } from '@angular/core';
18-
import { Gesture } from '@ionic/angular';
18+
import { Gesture, GestureDetail } from '@ionic/angular';
1919
import { GestureController } from '@singletons';
20+
2021
/**
2122
* Directive to add long press actions to html elements.
2223
*/
@@ -25,13 +26,13 @@ import { GestureController } from '@singletons';
2526
})
2627
export class CoreLongPressDirective implements OnInit, OnDestroy {
2728

28-
readonly HOLD_DURATION = 500;
29+
protected static readonly HOLD_DURATION = 500;
2930

3031
element: HTMLElement;
3132
pressGesture?: Gesture;
3233
timeout?: number;
3334

34-
@Output() longPress = new EventEmitter();
35+
@Output() longPress = new EventEmitter<GestureDetail>();
3536

3637
constructor(el: ElementRef) {
3738
this.element = el.nativeElement;
@@ -52,7 +53,7 @@ export class CoreLongPressDirective implements OnInit, OnDestroy {
5253
this.longPress.emit(event);
5354

5455
delete this.timeout;
55-
}, this.HOLD_DURATION);
56+
}, CoreLongPressDirective.HOLD_DURATION);
5657
},
5758
onMove: () => this.clearTimeout(),
5859
onEnd: () => this.clearTimeout(),

src/core/features/settings/pages/deviceinfo/deviceinfo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { CoreNetwork } from '@services/network';
3030
import { CoreLoginHelper } from '@features/login/services/login-helper';
3131
import { CoreSitesFactory } from '@services/sites-factory';
3232
import { CoreText } from '@singletons/text';
33+
import { GestureDetail } from '@ionic/angular';
3334

3435
/**
3536
* Device Info to be shown and copied to clipboard.
@@ -225,8 +226,8 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
225226
*
226227
* @param e Event.
227228
*/
228-
copyItemInfo(e: Event): void {
229-
const el = <Element>e.target;
229+
copyItemInfo(e: GestureDetail): void {
230+
const el = <Element>e.event.target;
230231
const text = el?.closest('ion-item')?.textContent?.trim();
231232

232233
text && CoreText.copyToClipboard(text);

0 commit comments

Comments
 (0)