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

Not all props are being generated in controls for a certain component #19155

Open
kestvirb opened this issue Sep 9, 2022 · 0 comments
Open

Comments

@kestvirb
Copy link

kestvirb commented Sep 9, 2022

Describe the bug
Not all props are being generated in controls for a certain component.

image

To Reproduce


export type ButtonProps = {
	variant?: ButtonVariant;
	color?: ButtonColor;
	size?: ButtonSize;
	loading?: boolean;
	component?: "button";
	innerRef?: Ref<any>;
	active?: boolean;
	startIcon?: string;
	endIcon?: string;
} & React.ButtonHTMLAttributes<HTMLButtonElement>;

export const Button = forwardRef(
	(
		{
			children,
			variant = "contained",
			color = "primary",
			size,
			className,
			disabled,
			active,
			component = "button",
			loading = false,
			type = "button",
			innerRef,
			startIcon,
			endIcon,
			...rest
		}: ButtonProps,
		ref
	) => {
		const accessabilityNames = () => {
			const accessabilityObj: ButtonAccessability = {};

			if (typeof children === "string") {
				return {
					"aria-label": children,
					title: children,
				};
			}

			if (rest.title) {
				accessabilityObj.title = rest.title;
				accessabilityObj["aria-label"] = rest["aria-label"];
			}

			if (rest["aria-label"]) {
				accessabilityObj.title = rest["aria-label"];
			}

			return accessabilityObj;
		};

		return React.createElement(
			component,
			{
				ref: innerRef || ref,
				className: classNames(
					{
						btn: true,
						disabled: disabled || loading,
						active,
					},
					formatButtonVariantAndColor(variant, color),
					size && formatBtnSize(size),
					className
				),
				type: type,
				disabled: disabled || loading,
				role: "button",
				...accessabilityNames(),
				...rest,
			},
			<>
				{startIcon && <Icon icon={startIcon} />}
				{children}
			</>
		);
	}
);

module.exports = {
	stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
	addons: ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-interactions", "@storybook/preset-scss"],
	framework: "@storybook/react",
	core: {
		builder: "@storybook/builder-webpack5",
	},
	typescript: {
		reactDocgen: "react-docgen-typescript",
		reactDocgenTypescriptOptions: {
			compilerOptions: {
				allowSyntheticDefaultImports: false,
				esModuleInterop: false,
			},
		},
	},
};
export default {
	title: "Button",
	component: ButtonComponent,
};

const Template = (args: any) => <ButtonComponent {...args}>Button</ButtonComponent>;

export const Button = Template.bind({});

Button.args = {
	startIcon: "",
	endIcon: "",
};

Additional context
I don't have issues with other components, even those using forwardRef, so was wondering what might be causing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant