Skip to content

Commit 77c6040

Browse files
committed
refactor: rename 'close' to 'remove' in Tabs component for improved clarity and consistency
1 parent 1b20c6f commit 77c6040

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

src/TabNavList/OperationNode.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export interface OperationNodeProps {
2828
getPopupContainer?: (node: HTMLElement) => HTMLElement;
2929
popupClassName?: string;
3030
popupStyle?: React.CSSProperties;
31-
styles?: Pick<Partial<Record<SemanticName, React.CSSProperties>>, 'close'>;
32-
classNames?: Pick<Partial<Record<SemanticName, string>>, 'close'>;
31+
styles?: Pick<Partial<Record<SemanticName, React.CSSProperties>>, 'remove'>;
32+
classNames?: Pick<Partial<Record<SemanticName, string>>, 'remove'>;
3333
}
3434

3535
const OperationNode = React.forwardRef<HTMLDivElement, OperationNodeProps>((props, ref) => {
@@ -103,8 +103,8 @@ const OperationNode = React.forwardRef<HTMLDivElement, OperationNodeProps>((prop
103103
type="button"
104104
aria-label={removeAriaLabel || 'remove'}
105105
tabIndex={0}
106-
className={clsx(`${dropdownPrefix}-menu-item-remove`, classNames?.close)}
107-
style={styles?.close}
106+
className={clsx(`${dropdownPrefix}-menu-item-remove`, classNames?.remove)}
107+
style={styles?.remove}
108108
onClick={e => {
109109
e.stopPropagation();
110110
onRemoveTab(e, key);

src/TabNavList/TabNode.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export interface TabNodeProps {
2424
onMouseUp: React.MouseEventHandler;
2525
onFocus: React.FocusEventHandler;
2626
onBlur: React.FocusEventHandler;
27-
styles?: Pick<Partial<Record<SemanticName, React.CSSProperties>>, 'item' | 'close'>;
28-
classNames?: Pick<Partial<Record<SemanticName, string>>, 'item' | 'close'>;
27+
styles?: Pick<Partial<Record<SemanticName, React.CSSProperties>>, 'item' | 'remove'>;
28+
classNames?: Pick<Partial<Record<SemanticName, string>>, 'item' | 'remove'>;
2929
}
3030

3131
const TabNode: React.FC<TabNodeProps> = props => {
@@ -131,8 +131,8 @@ const TabNode: React.FC<TabNodeProps> = props => {
131131
type="button"
132132
aria-label={removeAriaLabel || 'remove'}
133133
tabIndex={active ? 0 : -1}
134-
className={clsx(`${tabPrefix}-remove`, tabNodeClassNames?.close)}
135-
style={styles?.close}
134+
className={clsx(`${tabPrefix}-remove`, tabNodeClassNames?.remove)}
135+
style={styles?.remove}
136136
onClick={e => {
137137
e.stopPropagation();
138138
onRemoveTab(e);

src/TabNavList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,12 @@ const TabNavList = React.forwardRef<HTMLDivElement, TabNavListProps>((props, ref
437437
tab={tab}
438438
classNames={{
439439
item: tabsClassNames?.item,
440-
close: tabsClassNames?.close,
440+
remove: tabsClassNames?.remove,
441441
}}
442442
styles={{
443443
/* first node should not have margin left */
444444
item: i === 0 ? styles?.item : { ...tabNodeStyle, ...styles?.item },
445-
close: styles?.close,
445+
remove: styles?.remove,
446446
}}
447447
closable={tab.closable}
448448
editable={editable}

src/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import type {
3535
// Used for accessibility
3636
let uuid = 0;
3737

38-
export type SemanticName = 'popup' | 'item' | 'indicator' | 'content' | 'header' | 'close';
38+
export type SemanticName = 'popup' | 'item' | 'indicator' | 'content' | 'header' | 'remove';
3939

4040
export interface TabsProps
4141
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'children'> {

tests/index.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,12 @@ describe('Tabs.Basic', () => {
776776
expect(header).toHaveStyle({ background: 'yellow' });
777777
});
778778

779-
it('support classnames and styles for editable close button', () => {
779+
it('support classnames and styles for editable remove button', () => {
780780
const customClassNames = {
781-
close: 'custom-close',
781+
remove: 'custom-remove',
782782
};
783783
const customStyles = {
784-
close: { background: 'red' },
784+
remove: { background: 'red' },
785785
};
786786

787787
const { container } = render(
@@ -802,7 +802,7 @@ describe('Tabs.Basic', () => {
802802
</div>,
803803
);
804804

805-
expect(container.querySelector('.rc-tabs-tab-remove')).toHaveClass('custom-close');
805+
expect(container.querySelector('.rc-tabs-tab-remove')).toHaveClass('custom-remove');
806806
expect(container.querySelector('.rc-tabs-tab-remove')).toHaveStyle({ background: 'red' });
807807
});
808808
});

tests/overflow.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,13 @@ describe('Tabs.Overflow', () => {
528528
expect(document.querySelector('.rc-tabs-dropdown')).toHaveStyle('color: red');
529529
});
530530

531-
it('should support classnames and styles for editable close button', () => {
531+
it('should support classnames and styles for editable remove button', () => {
532532
jest.useFakeTimers();
533533
const { container } = render(
534534
getTabs({
535535
editable: { onEdit: () => {} },
536-
classNames: { close: 'custom-close' },
537-
styles: { close: { color: 'red' } },
536+
classNames: { remove: 'custom-remove' },
537+
styles: { remove: { color: 'red' } },
538538
}),
539539
);
540540

@@ -548,7 +548,7 @@ describe('Tabs.Overflow', () => {
548548
jest.runAllTimers();
549549
});
550550
expect(document.querySelector('.rc-tabs-dropdown-menu-item-remove')).toHaveClass(
551-
'custom-close',
551+
'custom-remove',
552552
);
553553
expect(document.querySelector('.rc-tabs-dropdown-menu-item-remove')).toHaveStyle({
554554
color: 'red',

0 commit comments

Comments
 (0)