Skip to content

chore: merge main into custom components templates#1239

Open
jwartofsky-yext wants to merge 8 commits into
2026-custom-components-templatesfrom
mergeMainIntoCustomComponentsTemplates
Open

chore: merge main into custom components templates#1239
jwartofsky-yext wants to merge 8 commits into
2026-custom-components-templatesfrom
mergeMainIntoCustomComponentsTemplates

Conversation

@jwartofsky-yext

@jwartofsky-yext jwartofsky-yext commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Merges the changes from the 1.3.3 release into the 2026-custom-components-templates branch

This includes these changes:

1.3.3 (2026-06-12)

New Features
Bug Fixes

jwartofsky-yext and others added 7 commits June 3, 2026 10:04
Allows EntityFieldSelector and itemSource to treat text fields as
satisfying a rich_text field.

This allows mapping rich_text fields to ordinary text fields and treats
objects with text fields as satisfying the rich_text requirement for
itemSource and slottedItemSource.

Verified that RichText fields can be mapped to ordinary Text fields.
Verified that ordinary Text fields cannot be mapped to RichText.

Verified that itemSource/slottedItemSource mapping requirements now
accept Text in place of RichText.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Removes the "Api Key" prop from the Static Map Section and Mapbox Static
Map components.

They now use the key from the environment variable.

If the key fails to load, the component will not appear on the live
page.

Tested using local starter.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
long emails before: 
<img width="686" height="205" alt="Screenshot 2026-06-09 at 1 54 42 PM"
src="https://github.com/user-attachments/assets/b09dfe11-168a-4c73-b0e7-d137624f6e0c"
/>
<img width="395" height="308" alt="Screenshot 2026-06-09 at 1 54 47 PM"
src="https://github.com/user-attachments/assets/2990e7d0-9816-477b-9d8d-43aa9fc179e2"
/>


after:
<img width="870" height="278" alt="Screenshot 2026-06-09 at 1 50 41 PM"
src="https://github.com/user-attachments/assets/b18134e2-a564-442c-89d5-4537e4298c3c"
/>
<img width="394" height="368" alt="Screenshot 2026-06-09 at 1 50 34 PM"
src="https://github.com/user-attachments/assets/7c6de2cc-b13e-413e-98a2-b5d2f708f869"
/>

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
In mobile view, display a "show more" button at the end of the search
results instead of pagination.

J=WAT-5580
TEST=manual

tested in dev mode and platform

https://drive.google.com/file/d/1Bw7xFbmvdOncZl37DXCalcTiLl3zod0n/view?usp=sharing

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@jwartofsky-yext jwartofsky-yext changed the title Merge main into custom components templates chore: merge main into custom components templates Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

⚠️ Deleted Translation Keys Detected

🔤 Deleted Translation Keys

fields

Key Languages Removed
fields.apiKey cs,da de,en en-GB,es et,fi fr,hr hu,it ja,lt lv,nb nl,pl pt,ro sk,sv tr,zh zh-TW

staticMapEmptyStateAddApiKey

Key Languages Removed
staticMapEmptyStateAddApiKey cs,da de,en en-GB,es et,fi fr,hr hu,it ja,lt lv,nb nl,pl pt,ro sk,sv tr,zh zh-TW

@jwartofsky-yext jwartofsky-yext marked this pull request as ready for review June 17, 2026 16:27
@jwartofsky-yext jwartofsky-yext requested review from asanehisa, benlife5, briantstephan and mkilpatrick and removed request for benlife5 and mkilpatrick June 17, 2026 16:27
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Version 1.3.3 bundles four functional changes. The Mapbox API key is now sourced from streamDocument._env.YEXT_MAPBOX_API_KEY (with a layout-editor override via YEXT_EDIT_LAYOUT_MODE_MAPBOX_API_KEY) instead of an apiKey component prop; migration 0078 strips the legacy apiKey/data props from saved component data. The Locator component detects mobile viewports using a new shared useViewport.ts hook and renders a MobileLocatorResultsSection with incremental "Show more locations" loading instead of pagination. ProfessionalHeroSection gains two configurable radio fields for horizontal subtitle alignment on mobile and desktop. The entity field selector now treats type.rich_text_v2 as compatible with type.string via a new getCompatibleEntityFieldTypes utility. Supporting changes include viewport utility consolidation away from header-local helpers, an email icon flex-shrink fix, and showMoreLocations/subtitleAlignment/staticMapEmptyStateMissingApiKey locale keys across 25 languages.

Possibly Related PRs

  • yext/visual-editor#1227: Directly overlaps — implements the same Mapbox API key migration, apiKey/data.apiKey prop removal from MapboxStaticMap/StaticMapSection, and staticMapEmptyStateMissingApiKey locale change.
  • yext/visual-editor#1237: Directly overlaps — modifies Locator.tsx to add mobileResults/mobile "Show more locations" pagination and updates Locator.test.tsx viewport handling.
  • yext/visual-editor#1234: Directly overlaps — adds subtitle alignment options to ProfessionalHeroSection.tsx with corresponding locale and docs updates.
🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'chore: merge main into custom components templates' does not describe the actual changes in the changeset. The PR contains extensive substantive changes including new localization strings, component modifications, migrations, and API key handling refactoring. It is not merely a merge/chore task. Consider retitling to reflect the primary changes, such as 'feat: add mobile locator show more locations and Mapbox API key refactoring' or provide a title that summarizes the key feature additions and refactoring work.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to evaluate relevance to the changeset. Consider adding a brief description explaining the purpose of merging main into the custom components templates branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mergeMainIntoCustomComponentsTemplates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/visual-editor/src/components/Locator.tsx`:
- Around line 1730-1744: The useEffect hook in the Locator component updates the
prevIsMobile.current ref on line 1733 before checking the searchLoading guard
condition. This causes the mobile transition flag to be consumed even when the
effect returns early due to a pending search, so subsequent invocations lose
track that a mobile switch occurred. Move the assignment of prevIsMobile.current
= isMobile to the end of the effect (after all the early return checks but
before the closing brace) so that the ref only gets updated when the effect
actually completes its mobile transition logic, not when it exits early.

In `@packages/visual-editor/src/docs/components.md`:
- Around line 806-809: The documentation for StaticMapSection currently does not
explicitly mention the required YEXT_MAPBOX_API_KEY environment variable
dependency, which could mislead users into thinking no configuration is needed.
Add clear documentation stating that StaticMapSection requires the
YEXT_MAPBOX_API_KEY environment variable (sourced from _env) to function
properly, and include any relevant setup instructions or notes about this
dependency.

In `@packages/visual-editor/src/internal/utils/getFilteredEntityFields.ts`:
- Around line 247-256: The forEach loop iterating through filter.types can add
the same field multiple times to updatedFilteredEntitySubFields because a field
may match both directly and through compatibility paths. After the forEach loop
completes but before assigning updatedFilteredEntitySubFields back to
filteredEntitySubFields, deduplicate the array by field.name to ensure each
field appears only once. Use a filter or reduce approach that keeps the first
occurrence of each unique field name, maintaining deterministic output for
direct callers.
- Around line 168-175: Remove the export statement from the
getCompatibleEntityFieldTypes function in getFilteredEntityFields.ts to keep it
internal and avoid expanding the src/internal public API surface. Instead of
exporting this helper, update the calling code in yextEntityFieldUtils.ts
(around line 357) to pass requiredTypes directly to getFilteredEntityFields and
let that function handle the entity field type compatibility expansion
internally in a single location rather than delegating it to a separate exported
utility function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4b962652-e596-404c-b15b-1b9b5556cf89

📥 Commits

Reviewing files that changed from the base of the PR and between 67c7baa and 2629421.

📒 Files selected for processing (73)
  • packages/visual-editor/CHANGELOG.md
  • packages/visual-editor/locales/components/cs/visual-editor.json
  • packages/visual-editor/locales/components/da/visual-editor.json
  • packages/visual-editor/locales/components/de/visual-editor.json
  • packages/visual-editor/locales/components/en-GB/visual-editor.json
  • packages/visual-editor/locales/components/en/visual-editor.json
  • packages/visual-editor/locales/components/es/visual-editor.json
  • packages/visual-editor/locales/components/et/visual-editor.json
  • packages/visual-editor/locales/components/fi/visual-editor.json
  • packages/visual-editor/locales/components/fr/visual-editor.json
  • packages/visual-editor/locales/components/hr/visual-editor.json
  • packages/visual-editor/locales/components/hu/visual-editor.json
  • packages/visual-editor/locales/components/it/visual-editor.json
  • packages/visual-editor/locales/components/ja/visual-editor.json
  • packages/visual-editor/locales/components/lt/visual-editor.json
  • packages/visual-editor/locales/components/lv/visual-editor.json
  • packages/visual-editor/locales/components/nb/visual-editor.json
  • packages/visual-editor/locales/components/nl/visual-editor.json
  • packages/visual-editor/locales/components/pl/visual-editor.json
  • packages/visual-editor/locales/components/pt/visual-editor.json
  • packages/visual-editor/locales/components/ro/visual-editor.json
  • packages/visual-editor/locales/components/sk/visual-editor.json
  • packages/visual-editor/locales/components/sv/visual-editor.json
  • packages/visual-editor/locales/components/tr/visual-editor.json
  • packages/visual-editor/locales/components/zh-TW/visual-editor.json
  • packages/visual-editor/locales/components/zh/visual-editor.json
  • packages/visual-editor/locales/platform/cs/visual-editor.json
  • packages/visual-editor/locales/platform/da/visual-editor.json
  • packages/visual-editor/locales/platform/de/visual-editor.json
  • packages/visual-editor/locales/platform/en-GB/visual-editor.json
  • packages/visual-editor/locales/platform/en/visual-editor.json
  • packages/visual-editor/locales/platform/es/visual-editor.json
  • packages/visual-editor/locales/platform/et/visual-editor.json
  • packages/visual-editor/locales/platform/fi/visual-editor.json
  • packages/visual-editor/locales/platform/fr/visual-editor.json
  • packages/visual-editor/locales/platform/hr/visual-editor.json
  • packages/visual-editor/locales/platform/hu/visual-editor.json
  • packages/visual-editor/locales/platform/it/visual-editor.json
  • packages/visual-editor/locales/platform/ja/visual-editor.json
  • packages/visual-editor/locales/platform/lt/visual-editor.json
  • packages/visual-editor/locales/platform/lv/visual-editor.json
  • packages/visual-editor/locales/platform/nb/visual-editor.json
  • packages/visual-editor/locales/platform/nl/visual-editor.json
  • packages/visual-editor/locales/platform/pl/visual-editor.json
  • packages/visual-editor/locales/platform/pt/visual-editor.json
  • packages/visual-editor/locales/platform/ro/visual-editor.json
  • packages/visual-editor/locales/platform/sk/visual-editor.json
  • packages/visual-editor/locales/platform/sv/visual-editor.json
  • packages/visual-editor/locales/platform/tr/visual-editor.json
  • packages/visual-editor/locales/platform/zh-TW/visual-editor.json
  • packages/visual-editor/locales/platform/zh/visual-editor.json
  • packages/visual-editor/package.json
  • packages/visual-editor/src/components/Locator.test.tsx
  • packages/visual-editor/src/components/Locator.tsx
  • packages/visual-editor/src/components/contentBlocks/Emails.tsx
  • packages/visual-editor/src/components/contentBlocks/MapboxStaticMap.tsx
  • packages/visual-editor/src/components/header/HeaderLinks.tsx
  • packages/visual-editor/src/components/header/PrimaryHeaderSlot.tsx
  • packages/visual-editor/src/components/header/viewport.ts
  • packages/visual-editor/src/components/migrations/0078_remove_mapbox_api_key_props.ts
  • packages/visual-editor/src/components/migrations/migrationRegistry.ts
  • packages/visual-editor/src/components/pageSections/ProfessionalHeroSection.tsx
  • packages/visual-editor/src/components/pageSections/StaticMapSection.test.tsx
  • packages/visual-editor/src/components/pageSections/StaticMapSection.tsx
  • packages/visual-editor/src/docs/components.md
  • packages/visual-editor/src/editor/yextEntityFieldUtils.test.ts
  • packages/visual-editor/src/editor/yextEntityFieldUtils.ts
  • packages/visual-editor/src/fields/EntityFieldSelectorField.test.tsx
  • packages/visual-editor/src/hooks/useViewport.ts
  • packages/visual-editor/src/internal/utils/getFilteredEntityFields.test.ts
  • packages/visual-editor/src/internal/utils/getFilteredEntityFields.ts
  • packages/visual-editor/src/utils/migrate.test.ts
  • starter/localData/dev-location-stream__en__cbafb9cd1c3e63d9814e236ba9181377.json
💤 Files with no reviewable changes (1)
  • packages/visual-editor/src/components/header/viewport.ts

Comment on lines +1730 to +1744
React.useEffect(() => {
const switchedToMobile = isMobile && !prevIsMobile.current;

prevIsMobile.current = isMobile;

if (!switchedToMobile || searchLoading || (currentOffset ?? 0) === 0) {
return;
}

// Always reload from offset 0 if switching to mobile
setMobileResults([]);
searchActions.setOffset(0);
executeSearch(searchActions);
setSearchState("loading");
}, [currentOffset, isMobile, searchActions, searchLoading]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix mobile switch detection when a query is in-flight.

On Line 1733, prevIsMobile.current is updated before the searchLoading guard. If the viewport switches to mobile while loading, the transition is consumed and the offset reset can be skipped.

Suggested fix
 React.useEffect(() => {
-  const switchedToMobile = isMobile && !prevIsMobile.current;
-
-  prevIsMobile.current = isMobile;
-
-  if (!switchedToMobile || searchLoading || (currentOffset ?? 0) === 0) {
+  if (searchLoading) {
     return;
   }
 
+  const switchedToMobile = isMobile && !prevIsMobile.current;
+  prevIsMobile.current = isMobile;
+
+  if (!switchedToMobile || (currentOffset ?? 0) === 0) {
+    return;
+  }
+
   // Always reload from offset 0 if switching to mobile
   setMobileResults([]);
   searchActions.setOffset(0);
   executeSearch(searchActions);
   setSearchState("loading");
 }, [currentOffset, isMobile, searchActions, searchLoading]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
React.useEffect(() => {
const switchedToMobile = isMobile && !prevIsMobile.current;
prevIsMobile.current = isMobile;
if (!switchedToMobile || searchLoading || (currentOffset ?? 0) === 0) {
return;
}
// Always reload from offset 0 if switching to mobile
setMobileResults([]);
searchActions.setOffset(0);
executeSearch(searchActions);
setSearchState("loading");
}, [currentOffset, isMobile, searchActions, searchLoading]);
React.useEffect(() => {
if (searchLoading) {
return;
}
const switchedToMobile = isMobile && !prevIsMobile.current;
prevIsMobile.current = isMobile;
if (!switchedToMobile || (currentOffset ?? 0) === 0) {
return;
}
// Always reload from offset 0 if switching to mobile
setMobileResults([]);
searchActions.setOffset(0);
executeSearch(searchActions);
setSearchState("loading");
}, [currentOffset, isMobile, searchActions, searchLoading]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/components/Locator.tsx` around lines 1730 - 1744,
The useEffect hook in the Locator component updates the prevIsMobile.current ref
on line 1733 before checking the searchLoading guard condition. This causes the
mobile transition flag to be consumed even when the effect returns early due to
a pending search, so subsequent invocations lose track that a mobile switch
occurred. Move the assignment of prevIsMobile.current = isMobile to the end of
the effect (after all the early return checks but before the closing brace) so
that the ref only gets updated when the effect actually completes its mobile
transition logic, not when it exits early.

Comment on lines +806 to 809
The Static Map Section displays a non-interactive map image of a business's location. It uses the entity's address or coordinates to generate the map.

Available on Location templates.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Document the environment key dependency explicitly.

StaticMapSection still requires YEXT_MAPBOX_API_KEY (now from _env), so the current wording can imply no key setup is needed.

Suggested docs tweak
-The Static Map Section displays a non-interactive map image of a business's location. It uses the entity's address or coordinates to generate the map.
+The Static Map Section displays a non-interactive map image of a business's location. It uses the entity's address or coordinates to generate the map.
+It requires `YEXT_MAPBOX_API_KEY` in site advanced configuration.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The Static Map Section displays a non-interactive map image of a business's location. It uses the entity's address or coordinates to generate the map.
Available on Location templates.
The Static Map Section displays a non-interactive map image of a business's location. It uses the entity's address or coordinates to generate the map.
It requires `YEXT_MAPBOX_API_KEY` in site advanced configuration.
Available on Location templates.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/docs/components.md` around lines 806 - 809, The
documentation for StaticMapSection currently does not explicitly mention the
required YEXT_MAPBOX_API_KEY environment variable dependency, which could
mislead users into thinking no configuration is needed. Add clear documentation
stating that StaticMapSection requires the YEXT_MAPBOX_API_KEY environment
variable (sourced from _env) to function properly, and include any relevant
setup instructions or notes about this dependency.

Comment on lines +168 to +175
export const getCompatibleEntityFieldTypes = (
entityFieldType: EntityFieldTypes
): EntityFieldTypes[] => {
return [
entityFieldType,
...(ENTITY_FIELD_TYPE_COMPATIBILITY[entityFieldType] ?? []),
];
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Keep compatibility expansion internal to avoid growing src/internal surface.

Line 168 exports a new helper from packages/visual-editor/src/internal, while Line 357 in packages/visual-editor/src/editor/yextEntityFieldUtils.ts can instead pass requiredTypes directly and let getFilteredEntityFields handle compatibility in one place.

Suggested simplification
diff --git a/packages/visual-editor/src/internal/utils/getFilteredEntityFields.ts b/packages/visual-editor/src/internal/utils/getFilteredEntityFields.ts
@@
-export const getCompatibleEntityFieldTypes = (
+const getCompatibleEntityFieldTypes = (
   entityFieldType: EntityFieldTypes
 ): EntityFieldTypes[] => {
   return [
     entityFieldType,
     ...(ENTITY_FIELD_TYPE_COMPATIBILITY[entityFieldType] ?? []),
   ];
 };
diff --git a/packages/visual-editor/src/editor/yextEntityFieldUtils.ts b/packages/visual-editor/src/editor/yextEntityFieldUtils.ts
@@
 import {
   getFilteredEntityFields,
-  getCompatibleEntityFieldTypes,
   RenderEntityFieldFilter,
 } from "../internal/utils/getFilteredEntityFields.ts";
@@
-              types: requiredTypes.flatMap(getCompatibleEntityFieldTypes),
+              types: requiredTypes,

As per coding guidelines, packages/visual-editor/src/internal/**/*.{ts,tsx}: “Do not publicly export modules from packages/visual-editor/src/internal; keep the public API surface small and intentional.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/internal/utils/getFilteredEntityFields.ts` around
lines 168 - 175, Remove the export statement from the
getCompatibleEntityFieldTypes function in getFilteredEntityFields.ts to keep it
internal and avoid expanding the src/internal public API surface. Instead of
exporting this helper, update the calling code in yextEntityFieldUtils.ts
(around line 357) to pass requiredTypes directly to getFilteredEntityFields and
let that function handle the entity field type compatibility expansion
internally in a single location rather than delegating it to a separate exported
utility function.

Source: Coding guidelines

Comment on lines 247 to 256
filter.types.forEach((type) => {
updatedFilteredEntitySubFields.push(
...filteredEntitySubFields.filter((field) => {
return typeToFieldNames.get(type)?.includes(field.name);
})
...getCompatibleEntityFieldTypes(type).flatMap((compatibleType) =>
filteredEntitySubFields.filter((field) =>
typeToFieldNames.get(compatibleType)?.includes(field.name)
)
)
);
});
filteredEntitySubFields = updatedFilteredEntitySubFields;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Deduplicate expanded type matches before returning filtered fields.

At Line 247, types: ["type.string", "type.rich_text_v2"] can push the same string field more than once (direct + compatibility path). Deduping by field.name keeps output deterministic for direct callers.

Proposed fix
     const updatedFilteredEntitySubFields: YextSchemaField[] = [];
     filter.types.forEach((type) => {
       updatedFilteredEntitySubFields.push(
         ...getCompatibleEntityFieldTypes(type).flatMap((compatibleType) =>
           filteredEntitySubFields.filter((field) =>
             typeToFieldNames.get(compatibleType)?.includes(field.name)
           )
         )
       );
     });
-    filteredEntitySubFields = updatedFilteredEntitySubFields;
+    filteredEntitySubFields = Array.from(
+      new Map(
+        updatedFilteredEntitySubFields.map((field) => [field.name, field])
+      ).values()
+    );
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
filter.types.forEach((type) => {
updatedFilteredEntitySubFields.push(
...filteredEntitySubFields.filter((field) => {
return typeToFieldNames.get(type)?.includes(field.name);
})
...getCompatibleEntityFieldTypes(type).flatMap((compatibleType) =>
filteredEntitySubFields.filter((field) =>
typeToFieldNames.get(compatibleType)?.includes(field.name)
)
)
);
});
filteredEntitySubFields = updatedFilteredEntitySubFields;
filter.types.forEach((type) => {
updatedFilteredEntitySubFields.push(
...getCompatibleEntityFieldTypes(type).flatMap((compatibleType) =>
filteredEntitySubFields.filter((field) =>
typeToFieldNames.get(compatibleType)?.includes(field.name)
)
)
);
});
filteredEntitySubFields = Array.from(
new Map(
updatedFilteredEntitySubFields.map((field) => [field.name, field])
).values()
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/visual-editor/src/internal/utils/getFilteredEntityFields.ts` around
lines 247 - 256, The forEach loop iterating through filter.types can add the
same field multiple times to updatedFilteredEntitySubFields because a field may
match both directly and through compatibility paths. After the forEach loop
completes but before assigning updatedFilteredEntitySubFields back to
filteredEntitySubFields, deduplicate the array by field.name to ensure each
field appears only once. Use a filter or reduce approach that keeps the first
occurrence of each unique field name, maintaining deterministic output for
direct callers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants