Skip to content

Commit 2ac9c30

Browse files
fix[plugins][commercetools]: ENG-7186 Component that uses Commercetools plugin doesn't update Builder UI when components are selected successively (BuilderIO#3656)
## Description - Update dependency from `@builder.io/commerce-plugin-tools` to `@builder.io/plugin-tools` as the former is deprecated. - Add fix for `resourceId` not updating on props change - Tested on CMS with local plugin URL. **Link to JIRA ticket:** https://builder-io.atlassian.net/browse/ENG-7186 **Screenshot** ![Screenshot 2024-10-22 at 4 50 35 PM](https://github.com/user-attachments/assets/847a5324-8737-49c8-8073-b5b622fdfc80) **Loom** https://www.loom.com/share/a9abb23801194f3c8ff967ea76af7b18
1 parent a54268d commit 2ac9c30

File tree

4 files changed

+8030
-22248
lines changed

4 files changed

+8030
-22248
lines changed

packages/plugin-tools/src/editors/ResourcesPicker.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ export const ResourcesPickerButton: React.FC<ResourcesPickerButtonProps> = props
189189
: typeof props.value === 'string'
190190
? props.value
191191
: props.value?.options?.get(props.resourceName),
192+
updateResourceId(newProps: ResourcesPickerButtonProps) {
193+
this.resourceId = newProps.handleOnly
194+
? undefined
195+
: typeof newProps.value === 'string'
196+
? newProps.value
197+
: newProps.value?.options?.get(newProps.resourceName);
198+
},
192199
async getResource() {
193200
this.error = null;
194201
this.loading = true;
@@ -254,8 +261,9 @@ export const ResourcesPickerButton: React.FC<ResourcesPickerButtonProps> = props
254261
}));
255262

256263
useEffect(() => {
264+
store.updateResourceId(props);
257265
store.getResource();
258-
}, []);
266+
}, [props.value]);
259267

260268
useEffect(() => {
261269
const hasPreviewFields = Boolean(

0 commit comments

Comments
 (0)