Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-controls: Dont show "setup controls" if control is disabled or a function #26120

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Changes from 3 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
7 changes: 4 additions & 3 deletions code/ui/blocks/src/components/ArgsTable/ArgControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export const ArgControl: FC<ArgControlProps> = ({ row, arg, updateArgs, isHovere
const onBlur = useCallback(() => setFocused(false), []);
const onFocus = useCallback(() => setFocused(true), []);

if (!control || control.disable)
return isHovered ? (
if (!control || control.disabled) {
const canBeSetup = control?.disabled !== true && row?.type?.name !== 'function';
return isHovered && canBeSetup ? (
<Link
href="https://storybook.js.org/docs/react/essentials/controls"
target="_blank"
Expand All @@ -77,7 +78,7 @@ export const ArgControl: FC<ArgControlProps> = ({ row, arg, updateArgs, isHovere
) : (
<NoControl />
);

}
// row.name is a display name and not a suitable DOM input id or name - i might contain whitespace etc.
// row.key is a hash key and therefore a much safer choice
const props = { name: key, argType: row, value: boxedValue.value, onChange, onBlur, onFocus };
Expand Down
Loading