From 754f6535d884d1e53bb8a92d94b6d2542ebdfa21 Mon Sep 17 00:00:00 2001 From: Simon R Date: Mon, 5 Jul 2021 18:27:46 +0200 Subject: [PATCH] Fix default options Fix deep-assign utility Fixes regression in #123 --- packages/vanilla/src/index.ts | 2 +- packages/vanilla/src/types.ts | 2 +- packages/vanilla/src/utils/deep-assign.ts | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/vanilla/src/index.ts b/packages/vanilla/src/index.ts index e4c8e7f..506b663 100644 --- a/packages/vanilla/src/index.ts +++ b/packages/vanilla/src/index.ts @@ -61,7 +61,7 @@ export default class SelectionArea extends EventTarget { behaviour: { overlap: 'invert', intersect: 'touch', - startThreshold: 10, + startThreshold: {x: 10, y: 10}, scrolling: { speedDivider: 10, manualSpeed: 750 diff --git a/packages/vanilla/src/types.ts b/packages/vanilla/src/types.ts index 74289aa..1f9b27e 100644 --- a/packages/vanilla/src/types.ts +++ b/packages/vanilla/src/types.ts @@ -86,7 +86,7 @@ export interface SelectionOptions { features: Features; } -export type PartialSelectionOptions = Partial & { +export type PartialSelectionOptions = Partial> & { behaviour?: Partial; features?: Partial; } diff --git a/packages/vanilla/src/utils/deep-assign.ts b/packages/vanilla/src/utils/deep-assign.ts index 3857019..251ed28 100644 --- a/packages/vanilla/src/utils/deep-assign.ts +++ b/packages/vanilla/src/utils/deep-assign.ts @@ -1,17 +1,16 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -export const deepAssign = (target: O, source: any): O => { - const result: Record = {}; - - for (const [key, value] of Object.entries(target)) { +export const deepAssign = (target: any, source: any): any => { + for (const [key, value] of Object.entries(source)) { // Use the default value if there's no value specified - result[key] = source[key] === undefined ? target[key as keyof O] : + target[key] = value === undefined ? target[key as keyof O] : // Check if it's a nested object and merge if required (typeof value === 'object' && value !== null && !Array.isArray(value)) ? - deepAssign(value as O, source[key] as Partial) : source[key]; + deepAssign(target[key], source[key] as Partial) : + source[key]; } - return result as O; + return target; };