Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions packages/plugin-tools/src/editors/ResourcesPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
TextField,
Typography,
} from '@material-ui/core';
import { Create, Search } from '@material-ui/icons';
import { Close, Create, Search } from '@material-ui/icons';
import { runInAction, action } from 'mobx';
import { useObserver, useLocalStore } from 'mobx-react';
import React, { useEffect } from 'react';
Expand Down Expand Up @@ -301,11 +301,11 @@ export const ResourcesPickerButton: React.FC<ResourcesPickerButtonProps> = props
position: 'relative',
}}
>
<ResourcePreviewCell button css={{ paddingRight: 30 }} resource={store.resourceInfo} />
<ResourcePreviewCell button css={{ paddingRight: 70 }} resource={store.resourceInfo} />
<IconButton
css={{
position: 'absolute',
right: 2,
right: 42,
top: 0,
bottom: 0,
height: 50,
Expand All @@ -318,6 +318,26 @@ export const ResourcesPickerButton: React.FC<ResourcesPickerButtonProps> = props
>
<Create css={{ color: '#888' }} />
</IconButton>
<IconButton
css={{
position: 'absolute',
right: 2,
top: 0,
bottom: 0,
height: 50,
marginTop: 'auto',
marginBottom: 'auto',
opacity: 0.7,
}}
onClick={action(() => {
store.resourceHandle = undefined;
store.resourceId = undefined;
store.resourceInfo = null;
props.onChange(null as any);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4d02a45. Configure here.

})}
>
<Close css={{ color: '#888' }} />
</IconButton>
</Paper>
)}
{!store.resourceInfo && !store.loading && (
Expand Down
Loading