Skip to content

Commit

Permalink
Dont show setup controls if control is disabled or a function
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen committed Feb 20, 2024
1 parent cbad3b1 commit 563d20b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions code/ui/blocks/src/components/ArgsTable/ArgControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {
RangeControl,
TextControl,
} from '../../controls';
import type { Args } from './types';
import type { InputType } from '@storybook/types';
import type { Args, ArgType } from './types';

export interface ArgControlProps {
row: InputType;
row: ArgType;
arg: any;
updateArgs: (args: Args) => void;
isHovered: boolean;
Expand Down Expand Up @@ -66,8 +65,9 @@ export const ArgControl: FC<ArgControlProps> = ({ row, arg, updateArgs, isHovere
const onBlur = useCallback(() => setFocused(false), []);
const onFocus = useCallback(() => setFocused(true), []);

if (!control && row.type !== 'function')
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 @@ -78,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
3 changes: 3 additions & 0 deletions code/ui/blocks/src/components/ArgsTable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export interface ArgType {
description?: string;
defaultValue?: any;
if?: Conditional;
type?: {
name?: string;
};
[key: string]: any;
}

Expand Down

0 comments on commit 563d20b

Please sign in to comment.