Skip to content

Commit

Permalink
fix(react): correctly apply overrides targeting single or multiple fi…
Browse files Browse the repository at this point in the history
…eld keys
  • Loading branch information
antoinechassagne committed Nov 18, 2024
1 parent 4685ef6 commit 46d8fef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
7 changes: 2 additions & 5 deletions packages/react/lib/Editable/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) =>
Expand Down
6 changes: 0 additions & 6 deletions packages/react/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

0 comments on commit 46d8fef

Please sign in to comment.