feat(plugin-tools): ENG-12227 add remove button to ResourcesPickerButton#4510
feat(plugin-tools): ENG-12227 add remove button to ResourcesPickerButton#4510Manish-Builder-io wants to merge 1 commit intomainfrom
Conversation
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>
|
|
View your CI Pipeline Execution ↗ for commit 4d02a45 ☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Passing
nullinstead ofundefinedbypasses type contract- Changed props.onChange(null as any) to props.onChange(undefined) to match the CustomReactEditorProps type contract and ensure correct clearing behavior.
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.
Reviewed by Cursor Bugbot for commit 4d02a45. Configure here.
| store.resourceHandle = undefined; | ||
| store.resourceId = undefined; | ||
| store.resourceInfo = null; | ||
| props.onChange(null as any); |
There was a problem hiding this comment.
Passing null instead of undefined bypasses type contract
Low Severity
The onChange callback type is onChange(val: BuilderRequest | string | undefined): void, which explicitly supports undefined for clearing a value. The remove handler passes null as any instead, bypassing TypeScript's type checking. Since null and undefined can have different semantics (e.g., null serializes in JSON while undefined strips the key), the parent component may handle them differently. Calling props.onChange(undefined) would match the type contract, avoid the as any cast, and guarantee correct clearing behavior.
Reviewed by Cursor Bugbot for commit 4d02a45. Configure here.



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
ResourcesPickerButtonso users can remove a selected resourceresourceHandle,resourceId,resourceInfoand callsonChange(null)to update the content JSON@builder.io/plugin-toolsTest plan
npm startScreenshot

If relevant, add a screenshot or two of the changes you made.
Before:
After fix:
Note
Medium Risk
Introduces new state-clearing behavior (
onChange(null)) for resource fields used across commerce plugins, which could affect downstream consumers that assume a value is always present. Otherwise the change is localized to editor UI controls and layout.Overview
Adds a remove (X) action to
ResourcesPickerButtonso a previously selected commerce resource can be cleared.When a resource is selected, the UI now shows both an edit (pencil) button and a close button; clicking close resets
resourceHandle/resourceId/resourceInfoand callsprops.onChange(null)to clear the field value, with minor layout tweaks to accommodate the extra icon.Reviewed by Cursor Bugbot for commit 4d02a45. Bugbot is set up for automated code reviews on this repo. Configure here.