Skip to content

Commit aa43c6f

Browse files
authored
chore: bug fix for staff step (#142)
* chore: bug fix for staff step * chore: scroll to the top * chore: update test
1 parent 92e9ead commit aa43c6f

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/components/StatusAlert/hooks/useSuccessAlerts.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const useSuccessAlerts = ({ step }) => {
2828
...alertTypes.success,
2929
};
3030
if (activeStepState === stepStates.inProgress) {
31-
if (activeStepName !== viewStep) {
31+
// startStepAction is null when the user is on the staff and submission steps
32+
if (activeStepName !== viewStep && startStepAction !== null) {
3233
successAlert.actions = [startStepAction.action];
3334
} else if (viewStep === stepNames.peer) {
3435
successAlert.actions = [loadNextAction.action];

src/components/StatusAlert/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const StatusAlert = ({
2525
);
2626

2727
React.useEffect(() => {
28-
window.scrollTo(0, 0);
28+
document.querySelector('html').scrollTo(0, 0);
2929
}, [hasSubmitted, step]);
3030

3131
if (isPageDataLoading) {

src/test/smoke.test.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ jest.mock('components/HotjarSurvey', () => 'HotjarSurvey');
4747
jest.unmock('react');
4848
jest.unmock('@edx/paragon');
4949

50+
jest.spyOn(document, 'querySelector').mockImplementation((selector) => {
51+
if (selector === 'html') {
52+
return {
53+
scrollTo: jest.fn(),
54+
};
55+
}
56+
return selector;
57+
});
58+
5059
const post = jest.fn();
5160
const lmsBaseUrl = 'test-base-url';
5261
const courseId = 'test-course-id';
@@ -102,8 +111,6 @@ const mockPageData = (url, { body, response }) => {
102111

103112
let el;
104113

105-
global.scrollTo = jest.fn();
106-
107114
describe('Integration smoke tests', () => {
108115
beforeEach(() => {
109116
jest.clearAllMocks();

0 commit comments

Comments
 (0)