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

[Bug]: ContentSwitcher docs do not align with component usage #18276

Open
2 tasks done
adamalston opened this issue Dec 26, 2024 · 0 comments
Open
2 tasks done

[Bug]: ContentSwitcher docs do not align with component usage #18276

adamalston opened this issue Dec 26, 2024 · 0 comments
Labels
adopter: strategic-product Work-stream that directly effects the Product-led Growth initiative. component: content-switcher role: dev 🤖 severity: 3 https://ibm.biz/carbon-severity type: bug 🐛

Comments

@adamalston
Copy link
Contributor

Package

@carbon/react

Browser

No response

Package version

1.67.1

React version

No response

Description

size and selectedIndex are not required according to the docs: https://react.carbondesignsystem.com/?path=/docs/components-contentswitcher--overview.

They are also not listed as required in the propTypes:

static propTypes = {
/**
* Pass in Switch components to be rendered in the ContentSwitcher
*/
children: PropTypes.node,
/**
* Specify an optional className to be added to the container node
*/
className: PropTypes.string,
/**
* `true` to use the light variant.
*/
light: deprecate(
PropTypes.bool,
'The `light` prop for `ContentSwitcher` is no longer needed and has ' +
'been deprecated. It will be removed in the next major release.'
),
/**
* Specify an `onChange` handler that is called whenever the ContentSwitcher
* changes which item is selected
*/
onChange: PropTypes.func.isRequired,
/**
* Specify a selected index for the initially selected content
*/
selectedIndex: PropTypes.number,
/**
* Choose whether or not to automatically change selection on focus when left/right arrow pressed. Defaults to 'automatic'
*/
selectionMode: PropTypes.oneOf(['automatic', 'manual']),
/**
* Specify the size of the Content Switcher. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
*/
size: PropTypes.oneOf(['sm', 'md', 'lg']),
};

However, these props are required per the interface for the component:

export interface ContentSwitcherProps
extends Omit<HTMLAttributes<HTMLElement>, 'onChange'> {
/**
* Pass in Switch components to be rendered in the ContentSwitcher
*/
children?: ReactElement[];
/**
* Specify an optional className to be added to the container node
*/
className?: string;
/**
* `true` to use the light version.
*
* @deprecated The `light` prop for `ContentSwitcher` has
* been deprecated in favor of the new `Layer` component. It will be removed in the next major release.
*/
light?: boolean;
/**
* Specify an `onChange` handler that is called whenever the ContentSwitcher
* changes which item is selected
*/
onChange: (params: SwitchEventHandlersParams) => void;
/**
* Specify a selected index for the initially selected content
*/
selectedIndex: number;
/**
* Choose whether or not to automatically change selection on focus when left/right arrow pressed. Defaults to 'automatic'
*/
selectionMode?: 'automatic' | 'manual';
/**
* Specify the size of the Content Switcher. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
*/
size: 'sm' | 'md' | 'lg';
}

Lastly, the prop type for size states:

Specify the size of the Content Switcher. Currently supports either sm, 'md' (default) or 'lg` as an option.

A default option shouldn't be necessary on a required property.

Reproduction/example

https://stackblitz.com/edit/github-eslv6tn5?file=src%2FApp.tsx

Steps to reproduce

See the error in the reproduction.

Suggested Severity

Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.

Application/PAL

DataPower

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adopter: strategic-product Work-stream that directly effects the Product-led Growth initiative. component: content-switcher role: dev 🤖 severity: 3 https://ibm.biz/carbon-severity type: bug 🐛
Projects
Status: ⏱ Backlog
Development

No branches or pull requests

2 participants