Skip to content

Commit

Permalink
fix(DataTable): correct default values for optional component props (#…
Browse files Browse the repository at this point in the history
…13804)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
lewandom and kodiakhq[bot] authored May 16, 2023
1 parent ffdce9a commit 6d29f6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/react/src/components/DataTable/TableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { useId } from '../../internal/useId';
import { usePrefix } from '../../internal/usePrefix';
import { ReactAttr } from '../../types/common';

const defaultScope = 'col';

const translationKeys: { [key: string]: string } = {
buttonDescription: 'carbon.table.header.icon.description',
};
Expand Down Expand Up @@ -101,7 +103,7 @@ interface TableHeaderProps
* attribute at the following URL:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope
*/
scope: string;
scope?: string;

/**
* Specify which direction we are currently sorting by, should be one of DESC,
Expand All @@ -128,7 +130,7 @@ const TableHeader = React.forwardRef(function TableHeader(
isSortable,
isSortHeader,
onClick,
scope,
scope = defaultScope,
sortDirection,
translateWithId: t,
id,
Expand Down Expand Up @@ -264,7 +266,7 @@ TableHeader.propTypes = {

TableHeader.defaultProps = {
isSortable: false,
scope: 'col',
scope: defaultScope,
translateWithId,
};

Expand Down
8 changes: 5 additions & 3 deletions packages/react/src/components/DataTable/TableToolbarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import React from 'react';
import { usePrefix } from '../../internal/usePrefix';
import OverflowMenu from '../OverflowMenu';

const defaultIconDescription = 'Settings';

export interface TableToolbarMenuProps
extends React.HTMLAttributes<HTMLDivElement> {
children: React.ReactNode;
Expand All @@ -24,7 +26,7 @@ export interface TableToolbarMenuProps
/**
* The description of the menu icon.
*/
iconDescription: string;
iconDescription?: string;

/**
* Optional prop to allow overriding the default menu icon
Expand All @@ -35,7 +37,7 @@ export interface TableToolbarMenuProps
const TableToolbarMenu: React.FC<TableToolbarMenuProps> = ({
className,
renderIcon,
iconDescription,
iconDescription = defaultIconDescription,
children,
...rest
}) => {
Expand All @@ -60,7 +62,7 @@ const TableToolbarMenu: React.FC<TableToolbarMenuProps> = ({

TableToolbarMenu.defaultProps = {
renderIcon: Settings,
iconDescription: 'Settings',
iconDescription: defaultIconDescription,
};

TableToolbarMenu.propTypes = {
Expand Down

0 comments on commit 6d29f6d

Please sign in to comment.