diff --git a/web/src/engine/osk/src/input/gestures/specsForLayout.ts b/web/src/engine/osk/src/input/gestures/specsForLayout.ts index 943d8e91b9..2648a660d0 100644 --- a/web/src/engine/osk/src/input/gestures/specsForLayout.ts +++ b/web/src/engine/osk/src/input/gestures/specsForLayout.ts @@ -248,7 +248,16 @@ export function gestureSetForLayout(flags: LayoutGestureSupportFlags, params: Ge const _initialTapModel: GestureModel = deepCopy(!doRoaming ? initialTapModel(params) : initialTapModelWithReset(params)); const _simpleTapModel: GestureModel = deepCopy(!doRoaming ? simpleTapModel(params) : simpleTapModelWithReset(params)); - const _longpressModel: GestureModel = deepCopy(longpressModel(params, true, doRoaming)); + // Ensure all deep-copy operations for longpress modeling occur before the property-redefining block. + const _longpressModel: GestureModel = withKeySpecFiltering(deepCopy(longpressModel(params, true, doRoaming)), 0); + + // `deepCopy` does not preserve property definitions, instead raw-copying its value. + // We need to re-instate the longpress delay property here. + Object.defineProperty(_longpressModel.contacts[0].model.timer, 'duration', { + get: () => { + return params.longpress.waitLength + } + }); // #region Functions for implementing and/or extending path initial-state checks function withKeySpecFiltering(model: GestureModel, contactIndices: number | number[]) { @@ -281,7 +290,7 @@ export function gestureSetForLayout(flags: LayoutGestureSupportFlags, params: Ge const specialStartModel = specialKeyStartModel(); const _modipressStartModel = modipressStartModel(); const gestureModels: GestureModel[] = [ - withKeySpecFiltering(_longpressModel, 0), + _longpressModel, withKeySpecFiltering(multitapStartModel(params), 0), multitapEndModel(params), _initialTapModel, @@ -481,7 +490,8 @@ export function longpressContactModel(params: GestureParams, enabledFlicks: bool itemPriority: 0, pathResolutionAction: 'resolve', timer: { - duration: spec.waitLength, + // Needs to be a getter so that it dynamically updates if the backing value is changed. + get duration() { return spec.waitLength }, expectedResult: true }, validateItem: (_: KeyElement, baseKey: KeyElement) => !!baseKey?.key.spec.sk,