feat: [v6] Retire deprecated api for auto-complete (#52198)
Some checks failed
Publish Any Commit / build (push) Has been cancelled
✅ test v6 / lint (push) Has been cancelled
✅ test v6 / test-react-legacy (18, 1/2) (push) Has been cancelled
✅ test v6 / test-react-legacy (18, 2/2) (push) Has been cancelled
✅ test v6 / test-node (push) Has been cancelled
✅ test v6 / test-react-latest (dom, 1/2) (push) Has been cancelled
✅ test v6 / test-react-latest (dom, 2/2) (push) Has been cancelled
✅ test v6 / build (push) Has been cancelled
✅ test v6 / test lib/es module (es, 1/2) (push) Has been cancelled
✅ test v6 / test lib/es module (es, 2/2) (push) Has been cancelled
✅ test v6 / test lib/es module (lib, 1/2) (push) Has been cancelled
✅ test v6 / test lib/es module (lib, 2/2) (push) Has been cancelled
👁️ Visual Regression Persist Start / test image (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist, 1/2) (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist, 2/2) (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist-min, 1/2) (push) Has been cancelled
✅ test v6 / test-react-latest-dist (dist-min, 2/2) (push) Has been cancelled
✅ test v6 / test-coverage (push) Has been cancelled

This commit is contained in:
kiner-tang(星河) 2025-01-02 11:35:36 +08:00 committed by GitHub
parent f617e33448
commit 8e8f4e7613
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 35 deletions

View File

@ -2,7 +2,6 @@ import React from 'react';
import userEvent from '@testing-library/user-event';
import AutoComplete from '..';
import { resetWarned } from '../../_util/warning';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { render, screen } from '../../../tests/utils';
@ -97,24 +96,4 @@ describe('AutoComplete', () => {
);
expect(screen.getByRole('combobox')).toHaveClass('custom');
});
it('deprecated dropdownClassName', () => {
resetWarned();
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container } = render(
<AutoComplete
dropdownClassName="legacy"
open
options={[{ label: 'little', value: 'little' }]}
searchValue="l"
/>,
);
expect(errSpy).toHaveBeenCalledWith(
'Warning: [antd: AutoComplete] `dropdownClassName` is deprecated. Please use `popupClassName` instead.',
);
expect(container.querySelector('.legacy')).toBeTruthy();
errSpy.mockRestore();
});
});

View File

@ -38,8 +38,6 @@ export interface AutoCompleteProps<
dataSource?: DataSourceItemType[];
status?: InputStatus;
popupClassName?: string;
/** @deprecated Please use `popupClassName` instead */
dropdownClassName?: string;
/** @deprecated Please use `popupMatchSelectWidth` instead */
dropdownMatchSelectWidth?: boolean | number;
popupMatchSelectWidth?: boolean | number;
@ -53,14 +51,7 @@ const AutoComplete: React.ForwardRefRenderFunction<RefSelectProps, AutoCompleteP
props,
ref,
) => {
const {
prefixCls: customizePrefixCls,
className,
popupClassName,
dropdownClassName,
children,
dataSource,
} = props;
const { prefixCls: customizePrefixCls, className, popupClassName, children, dataSource } = props;
const childNodes: React.ReactElement[] = toArray(children);
// ============================= Input =============================
@ -120,8 +111,6 @@ const AutoComplete: React.ForwardRefRenderFunction<RefSelectProps, AutoCompleteP
'usage',
'You need to control style self instead of setting `size` when using customize input.',
);
warning.deprecated(!dropdownClassName, 'dropdownClassName', 'popupClassName');
}
const { getPrefixCls } = React.useContext<ConfigConsumerProps>(ConfigContext);
@ -135,9 +124,9 @@ const AutoComplete: React.ForwardRefRenderFunction<RefSelectProps, AutoCompleteP
<Select
ref={ref}
suffixIcon={null}
{...omit(props, ['dataSource', 'dropdownClassName'])}
{...omit(props, ['dataSource'])}
prefixCls={prefixCls}
popupClassName={popupClassName || dropdownClassName}
popupClassName={popupClassName}
dropdownStyle={{
...props.dropdownStyle,
zIndex,