From 46d8fefcc75f2a4a400b70093d38c73e98b8e3ac Mon Sep 17 00:00:00 2001 From: Antoine Chassagne Date: Mon, 18 Nov 2024 10:48:51 +0100 Subject: [PATCH] fix(react): correctly apply overrides targeting single or multiple field keys --- packages/react/lib/Editable/Tab.tsx | 7 ++----- packages/react/lib/utils.ts | 6 ------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/react/lib/Editable/Tab.tsx b/packages/react/lib/Editable/Tab.tsx index 3879bd4de..5674fa0ea 100644 --- a/packages/react/lib/Editable/Tab.tsx +++ b/packages/react/lib/Editable/Tab.tsx @@ -21,7 +21,6 @@ import type { EditableRef } from './index'; import { useBuilder } from '../hooks'; import Setting from './Setting'; import SettingsGroup from './SettingsGroup'; -import { areArraysEqual } from '../utils'; export interface TabProps extends ComponentPropsWithoutRef<'div'> { tab: ComponentSettingsTabObject | ComponentSettingsFieldObject; @@ -85,10 +84,8 @@ const Tab = ({ !component.settings?.fields?.find(s => s.type !== 'tab' && ((s as ComponentSettingsFieldObject).key === f.key || - areArraysEqual( - (s as ComponentSettingsFieldObject).key as string[], - f.key as string[] - )) + [].concat((s as ComponentSettingsFieldObject).key) + .some(k => [].concat(f.key).includes(k))) ) ) || []) .filter((field: ComponentSettingsFieldObject) => diff --git a/packages/react/lib/utils.ts b/packages/react/lib/utils.ts index b7a2258dd..e79233937 100644 --- a/packages/react/lib/utils.ts +++ b/packages/react/lib/utils.ts @@ -31,9 +31,3 @@ export const sanitizeHTML = (content: string, opts?: { return ''; } }; - -export const areArraysEqual = (a: any[], b: any[]) => - Array.isArray(a) && - Array.isArray(b) && - a.length === b.length && - a.every((v, i) => v === b[i]);