Skip to content

feat(plugin-tools): ENG-12227 add remove button to ResourcesPickerButton#4510

Merged
sanyamkamat merged 5 commits intomainfrom
feat/plugin-tools-remove-resource-button
Apr 20, 2026
Merged

feat(plugin-tools): ENG-12227 add remove button to ResourcesPickerButton#4510
sanyamkamat merged 5 commits intomainfrom
feat/plugin-tools-remove-resource-button

Conversation

@Manish-Builder-io
Copy link
Copy Markdown
Contributor

@Manish-Builder-io Manish-Builder-io commented Apr 13, 2026

Commerce plugins (CommerceLayer, SFCC, etc.) had no way to remove a selected resource once added. This adds a Close icon button next to the existing edit button that clears the selection and updates the content JSON, matching the pattern used by the reference field type.

https://www.loom.com/share/10758e859af547dca10fad16fa4bb71e

Description

Summary

  • Adds a Close (X) icon button next to the existing edit (pencil) button in ResourcesPickerButton so users can remove a selected resource
  • Clears resourceHandle, resourceId, resourceInfo and calls onChange(null) to update the content JSON
  • Applies to all commerce plugins (CommerceLayer, Shopify, SFCC, etc.) since they share @builder.io/plugin-tools

Test plan

  • Load a commerce plugin (e.g. CommerceLayer) locally via npm start
  • Add a product/resource field to a model and select a product
  • Verify both edit (pencil) and remove (X) buttons appear on the selected resource
  • Click the X button and verify the resource is removed from the UI and cleared from the content JSON
  • Verify clicking "Choose {resourceName}" allows re-selecting a new resource after removal

Screenshot
If relevant, add a screenshot or two of the changes you made.
Before:
Screenshot 2026-04-13 at 8 33 40 PM

After fix:

Screenshot 2026-04-13 at 8 34 43 PM

Note

Medium Risk
Moderate risk because it changes the CustomReactEditorProps.onChange type to accept null, which may require downstream TypeScript updates, and adjusts CommerceLayer’s build pipeline dependencies/plugins.

Overview
Adds a remove (Close/X) action to ResourcesPickerButton so a previously selected commerce resource can be cleared; it resets local selection state and calls onChange(null).

Updates the shared editor prop type to allow null values, bumps @builder.io/plugin-tools to 0.0.10, and updates the CommerceLayer plugin to consume it while also tweaking Rollup config/deps (adds @rollup/plugin-commonjs and marks @builder.io/sdk as external).

Reviewed by Cursor Bugbot for commit 63b86d6. Bugbot is set up for automated code reviews on this repo. Configure here.

Commerce plugins (CommerceLayer, Shopify, SFCC, etc.) had no way to
remove a selected resource once added. This adds a Close icon button
next to the existing edit button that clears the selection and updates
the content JSON, matching the pattern used by the reference field type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

⚠️ No Changeset found

Latest commit: 63b86d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 13, 2026

View your CI Pipeline Execution ↗ for commit 63b86d6

Command Status Duration Result
nx test @e2e/qwik-city ✅ Succeeded 7m 45s View ↗
nx test @e2e/nextjs-sdk-next-app ✅ Succeeded 7m 7s View ↗
nx test @e2e/nuxt ✅ Succeeded 5m 52s View ↗
nx test @e2e/angular-17 ✅ Succeeded 6m 21s View ↗
nx test @e2e/gen1-remix ✅ Succeeded 5m 11s View ↗
nx test @e2e/angular-17-ssr ✅ Succeeded 5m 24s View ↗
nx test @e2e/react-sdk-next-14-app ✅ Succeeded 5m 13s View ↗
nx test @e2e/gen1-next15-app ✅ Succeeded 4m 57s View ↗
Additional runs (38) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-04-20 06:03:43 UTC

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Passing null instead of undefined bypasses type contract
    • Changed props.onChange(null as any) to props.onChange(undefined) to match the CustomReactEditorProps type contract and ensure correct clearing behavior.

Create PR

Or push these changes by commenting:

@cursor push d80dc52efe
Preview (d80dc52efe)
diff --git a/packages/plugin-tools/src/editors/ResourcesPicker.tsx b/packages/plugin-tools/src/editors/ResourcesPicker.tsx
--- a/packages/plugin-tools/src/editors/ResourcesPicker.tsx
+++ b/packages/plugin-tools/src/editors/ResourcesPicker.tsx
@@ -333,7 +333,7 @@
                 store.resourceHandle = undefined;
                 store.resourceId = undefined;
                 store.resourceInfo = null;
-                props.onChange(null as any);
+                props.onChange(undefined);
               })}
             >
               <Close css={{ color: '#888' }} />

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread packages/plugin-tools/src/editors/ResourcesPicker.tsx Outdated
@sanyamkamat
Copy link
Copy Markdown
Contributor

@builderio-bot look at latest PR feedback and fix anything you agree with. Be skeptical. Reply to every comment if you fixed it or not and why

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9e09605. Configure here.

export interface CustomReactEditorProps<T = any> {
value?: T;
onChange(val: T | undefined): void;
onChange(val: T | undefined | null): void;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

value type excludes null despite onChange accepting it

Medium Severity

The onChange signature was updated to accept null, but value remains typed as T | undefined (via the ? modifier). After calling onChange(null), the framework will likely set value to null on re-render, but the type doesn't reflect this. Consumers checking typeof value === 'undefined' to detect an unset state (as done in ResourcesList.tsx) would incorrectly treat null as a set value. The value type needs to include null to match the onChange contract.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9e09605. Configure here.

@sanyamkamat sanyamkamat enabled auto-merge (squash) April 20, 2026 05:55
@sanyamkamat sanyamkamat disabled auto-merge April 20, 2026 06:16
@sanyamkamat sanyamkamat merged commit dbc43f0 into main Apr 20, 2026
48 checks passed
@sanyamkamat sanyamkamat deleted the feat/plugin-tools-remove-resource-button branch April 20, 2026 06:16
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.

2 participants