Skip to content

Commit c23659e

Browse files
authored
fix(Toolbar*): change spelling of visiblity prop (#4555)
deprecate visiblity prop and add visibility prop in ToolbarItem, Toolbar Content, ToolbarGroup, and ToolbarToggleGroup fix #4501
1 parent e0f743d commit c23659e

File tree

4 files changed

+84
-5
lines changed

4 files changed

+84
-5
lines changed

packages/react-core/src/components/Toolbar/ToolbarContent.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export interface ToolbarContentProps extends React.HTMLProps<HTMLDivElement> {
99
/** Classes applied to root element of the data toolbar content row */
1010
className?: string;
1111
/** Visibility at various breakpoints. */
12+
visibility?: {
13+
default?: 'hidden' | 'visible';
14+
md?: 'hidden' | 'visible';
15+
lg?: 'hidden' | 'visible';
16+
xl?: 'hidden' | 'visible';
17+
'2xl'?: 'hidden' | 'visible';
18+
};
19+
/** Deprecated: prop misspelled */
1220
visiblity?: {
1321
default?: 'hidden' | 'visible';
1422
md?: 'hidden' | 'visible';
@@ -55,6 +63,7 @@ export class ToolbarContent extends React.Component<ToolbarContentProps> {
5563
children,
5664
isExpanded,
5765
toolbarId,
66+
visibility,
5867
visiblity,
5968
alignment,
6069
clearAllFilters,
@@ -63,11 +72,19 @@ export class ToolbarContent extends React.Component<ToolbarContentProps> {
6372
...props
6473
} = this.props;
6574

75+
if (visiblity !== undefined) {
76+
// eslint-disable-next-line no-console
77+
console.warn(
78+
'The ToolbarContent visiblity prop has been deprecated. ' +
79+
'Please use the correctly spelled visibility prop instead.'
80+
);
81+
}
82+
6683
return (
6784
<div
6885
className={css(
6986
styles.toolbarContent,
70-
formatBreakpointMods(visiblity, styles),
87+
formatBreakpointMods(visibility || visiblity, styles),
7188
formatBreakpointMods(alignment, styles),
7289
className
7390
)}

packages/react-core/src/components/Toolbar/ToolbarGroup.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export interface ToolbarGroupProps extends Omit<React.HTMLProps<HTMLDivElement>,
1515
/** A type modifier which modifies spacing specifically depending on the type of group */
1616
variant?: ToolbarGroupVariant | 'filter-group' | 'icon-button-group' | 'button-group';
1717
/** Visibility at various breakpoints. */
18+
visibility?: {
19+
default?: 'hidden' | 'visible';
20+
md?: 'hidden' | 'visible';
21+
lg?: 'hidden' | 'visible';
22+
xl?: 'hidden' | 'visible';
23+
'2xl'?: 'hidden' | 'visible';
24+
};
25+
/** Deprecated: prop misspelled */
1826
visiblity?: {
1927
default?: 'hidden' | 'visible';
2028
md?: 'hidden' | 'visible';
@@ -54,13 +62,33 @@ export interface ToolbarGroupProps extends Omit<React.HTMLProps<HTMLDivElement>,
5462

5563
class ToolbarGroupWithRef extends React.Component<ToolbarGroupProps> {
5664
render() {
57-
const { visiblity, alignment, spacer, spaceItems, className, variant, children, innerRef, ...props } = this.props;
65+
const {
66+
visibility,
67+
visiblity,
68+
alignment,
69+
spacer,
70+
spaceItems,
71+
className,
72+
variant,
73+
children,
74+
innerRef,
75+
...props
76+
} = this.props;
77+
78+
if (visiblity !== undefined) {
79+
// eslint-disable-next-line no-console
80+
console.warn(
81+
'The ToolbarGroup visiblity prop has been deprecated. ' +
82+
'Please use the correctly spelled visibility prop instead.'
83+
);
84+
}
85+
5886
return (
5987
<div
6088
className={css(
6189
styles.toolbarGroup,
6290
variant && styles.modifiers[toCamel(variant) as 'filterGroup' | 'iconButtonGroup' | 'buttonGroup'],
63-
formatBreakpointMods(visiblity, styles),
91+
formatBreakpointMods(visibility || visiblity, styles),
6492
formatBreakpointMods(alignment, styles),
6593
formatBreakpointMods(spacer, styles),
6694
formatBreakpointMods(spaceItems, styles),

packages/react-core/src/components/Toolbar/ToolbarItem.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export interface ToolbarItemProps extends React.HTMLProps<HTMLDivElement> {
2929
| 'chip-group'
3030
| 'separator';
3131
/** Visibility at various breakpoints. */
32+
visibility?: {
33+
default?: 'hidden' | 'visible';
34+
md?: 'hidden' | 'visible';
35+
lg?: 'hidden' | 'visible';
36+
xl?: 'hidden' | 'visible';
37+
'2xl'?: 'hidden' | 'visible';
38+
};
39+
/** Deprecated: prop misspelled */
3240
visiblity?: {
3341
default?: 'hidden' | 'visible';
3442
md?: 'hidden' | 'visible';
@@ -61,6 +69,7 @@ export interface ToolbarItemProps extends React.HTMLProps<HTMLDivElement> {
6169
export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({
6270
className,
6371
variant,
72+
visibility,
6473
visiblity,
6574
alignment,
6675
spacer,
@@ -72,6 +81,14 @@ export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({
7281
return <Divider className={css(styles.modifiers.vertical, className)} {...props} />;
7382
}
7483

84+
if (visiblity !== undefined) {
85+
// eslint-disable-next-line no-console
86+
console.warn(
87+
'The ToolbarItem visiblity prop has been deprecated. ' +
88+
'Please use the correctly spelled visibility prop instead.'
89+
);
90+
}
91+
7592
return (
7693
<div
7794
className={css(
@@ -80,7 +97,7 @@ export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({
8097
styles.modifiers[
8198
toCamel(variant) as 'bulkSelect' | 'overflowMenu' | 'pagination' | 'searchFilter' | 'label' | 'chipGroup'
8299
],
83-
formatBreakpointMods(visiblity, styles),
100+
formatBreakpointMods(visibility || visiblity, styles),
84101
formatBreakpointMods(alignment, styles),
85102
formatBreakpointMods(spacer, styles),
86103
className

packages/react-core/src/components/Toolbar/ToolbarToggleGroup.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export interface ToolbarToggleGroupProps extends ToolbarGroupProps {
1515
/** Controls when filters are shown and when the toggle button is hidden. */
1616
breakpoint: 'md' | 'lg' | 'xl' | '2xl';
1717
/** Visibility at various breakpoints. */
18+
visibility?: {
19+
default?: 'hidden' | 'visible';
20+
md?: 'hidden' | 'visible';
21+
lg?: 'hidden' | 'visible';
22+
xl?: 'hidden' | 'visible';
23+
'2xl'?: 'hidden' | 'visible';
24+
};
25+
/** Deprecated: prop misspelled */
1826
visiblity?: {
1927
default?: 'hidden' | 'visible';
2028
md?: 'hidden' | 'visible';
@@ -60,6 +68,7 @@ export class ToolbarToggleGroup extends React.Component<ToolbarToggleGroupProps>
6068
const {
6169
toggleIcon,
6270
variant,
71+
visibility,
6372
visiblity,
6473
breakpoint,
6574
alignment,
@@ -75,6 +84,14 @@ export class ToolbarToggleGroup extends React.Component<ToolbarToggleGroupProps>
7584
console.error('ToolbarToggleGroup will not be visible without a breakpoint or toggleIcon.');
7685
}
7786

87+
if (visiblity !== undefined) {
88+
// eslint-disable-next-line no-console
89+
console.warn(
90+
'The ToolbarToggleGroup visiblity prop has been deprecated. ' +
91+
'Please use the correctly spelled visibility prop instead.'
92+
);
93+
}
94+
7895
return (
7996
<ToolbarContext.Consumer>
8097
{({ isExpanded, toggleIsExpanded }) => (
@@ -102,7 +119,7 @@ export class ToolbarToggleGroup extends React.Component<ToolbarToggleGroupProps>
102119
| 'showOnXl'
103120
| 'showOn_2xl'
104121
],
105-
formatBreakpointMods(visiblity, styles),
122+
formatBreakpointMods(visibility || visiblity, styles),
106123
formatBreakpointMods(alignment, styles),
107124
formatBreakpointMods(spacer, styles),
108125
formatBreakpointMods(spaceItems, styles),

0 commit comments

Comments
 (0)