Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions components/spin/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ describe('Spin', () => {
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();
});

it('right style when fullscreen', () => {
const { container } = render(<Spin fullscreen spinning />);
const element = container.querySelector<HTMLDivElement>('.ant-spin.ant-spin-fullscreen');
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 pattern.');
li-jia-nan marked this conversation as resolved.
Show resolved Hide resolved
}

const { direction, spin } = React.useContext<ConfigConsumerProps>(ConfigContext);
Expand Down