Skip to content

Commit

Permalink
fix(spin): remove false positive warning with tip and fullscreen
Browse files Browse the repository at this point in the history
…used together (#47015)

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

* fix(spin): update warning text
  • Loading branch information
xsjcTony committed Jan 19, 2024
1 parent e727b04 commit 87b45e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion components/spin/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
4 changes: 2 additions & 2 deletions components/spin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const Spin: SpinType = (props) => {
wrapperClassName,
style,
children,
fullscreen,
fullscreen = false,
...restProps
} = props;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 87b45e6

Please sign in to comment.