fix(spin): remove false positive warning with tip and fullscreen used together (#47015)

* fix(spin): remove false positive warning with `tip` and `fullscreen` used together

* fix(spin): update warning text
This commit is contained in:
Aelita 2024-01-20 01:20:50 +11:00 committed by GitHub
parent e727b04fa6
commit 87b45e6198
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -69,7 +69,18 @@ describe('Spin', () => {
const { container } = render(<Spin tip="Not Show" />);
expect(container.querySelector('.ant-spin-text')).toBeFalsy();
expect(errSpy).toHaveBeenCalledWith('Warning: [antd: Spin] `tip` only work in nest pattern.');
expect(errSpy).toHaveBeenCalledWith('Warning: [antd: Spin] `tip` only work in nest or fullscreen pattern.');
errSpy.mockRestore();
});
it('should not warn tip with fullscreen', () => {
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container } = render(<Spin fullscreen tip="Fullscreen" />);
expect(container.querySelector('.ant-spin-fullscreen')).toBeTruthy();
expect(errSpy).not.toHaveBeenCalled();
errSpy.mockRestore();
});

View File

@ -82,7 +82,7 @@ const Spin: SpinType = (props) => {
wrapperClassName,
style,
children,
fullscreen,
fullscreen = false,
...restProps
} = props;
@ -118,7 +118,7 @@ const Spin: SpinType = (props) => {
if (process.env.NODE_ENV !== 'production') {
const warning = devUseWarning('Spin');
warning(!tip || isNestedPattern, 'usage', '`tip` only work in nest pattern.');
warning(!tip || isNestedPattern || fullscreen, 'usage', '`tip` only work in nest or fullscreen pattern.');
}
const { direction, spin } = React.useContext<ConfigConsumerProps>(ConfigContext);