fix: Tour should not trigger onNext if finish (#38347)

* fix: Tour should not trigger onNext if finish

* test: update test case

* chore: update test case
This commit is contained in:
MadCcc 2022-11-02 21:54:55 +08:00 committed by GitHub
parent b0850139f2
commit abf45ca898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -176,7 +176,7 @@ describe('Tour', () => {
};
const { getByText, container } = render(<App />);
expect(getByText('primary description.')).toBeTruthy();
expect(document.querySelector('.ant-tour')).toHaveClass('ant-tour-primary');
expect(container.querySelector('.ant-tour')).toHaveClass('ant-tour-primary');
expect(container.firstChild).toMatchSnapshot();
});
@ -251,7 +251,7 @@ describe('Tour', () => {
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(getByText('Adjust Placement')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Finish' }));
expect(document.querySelector('.rc-tour')).toBeFalsy();
expect(container.querySelector('.ant-tour')).toBeFalsy();
expect(container.firstChild).toMatchSnapshot();
});
});

View File

@ -38,9 +38,10 @@ const panelRender: (
};
const nextBtnClick = () => {
onNext?.();
if (isLastStep) {
onFinish?.();
} else {
onNext?.();
}
if (typeof nextButtonProps?.onClick === 'function') {
nextButtonProps?.onClick();

View File

@ -114,7 +114,7 @@
"@ant-design/react-slick": "~0.29.1",
"@babel/runtime": "^7.18.3",
"@ctrl/tinycolor": "^3.4.0",
"@rc-component/tour": "~1.0.0-9",
"@rc-component/tour": "~1.0.0",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.2.0",
"dayjs": "^1.11.1",