Course home: clearing `start_course` adds a history entry

Open Beginner friendly
#2,265 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, react
Domain
frontend

Research direction

Start in src/course-home/outline-tab/OutlineTab.jsx around lines 102-117, the effect that strips ?start_course=1 after sending enrollment.email.clicked.startcourse; the call passes replace: true inside the To object instead of the second options argument. Compare with WeeklyLearningGoalCard.jsx, which still uses history.replace for weekly_goal. Read the v6 useNavigate docs on options.replace, then check the existing outline-tab tests for the router setup and add a case asserting the cleanup navigation was a replace, not a push. Done means Back leaves the course home after arriving with ?start_course=1, the event fires once, and that test fails against the current call.

Written by the indexing model from the issue text.

Description

Clearing start_course adds a history entry. When a learner opens the course home from the enrollment email, the outline tab sends the enrollment.email.clicked.startcourse event and takes ?start_course=1 out of the address. It does that with a new history entry, where it means to replace the current one. Back then returns to the ?start_course=1 address, the event is sent a second time, and the learner is moved forward again. It has been this way since #1128 (2023-10), the React Router v6 upgrade.

A test of the same call shows the router recording the navigation as a push. What Back does follows from that and has not been watched in a browser.

Status (2026-11-18): fixed in the frontend-base version of Learning, the package under frontend-base/ on the frontend-base branch, by #2252. The frontend-build and frontend-platform version under src/ still has it.

[!NOTE]
This issue was written by Claude (Claude Code) and reviewed before posting.

Claude Plan

Mechanism

  • OutlineTab.jsx clears the parameter with navigate({ pathname, search, replace: true }): replace is a key of the first argument.

  • React Router's navigate takes replace in its second argument. From the useNavigate page of the v6 documentation:

    Either pass a To value (same type as <Link to>) with an optional second options argument

    and, under options.replace:

    Specifying replace: true will cause the navigation to replace the current entry in the history stack instead of adding a new one.

  • A To object carries a pathname, a search string and a hash. A replace key in it is not read, so the call navigates with the default, a push.

History

  • #1128 (2023-10-05) turned history.replace({ search: currentParams.toString() }) into the navigate call and put replace: true in the first argument (the commit).
  • The weekly goal card's cleanup of weekly_goal, in WeeklyLearningGoalCard.jsx, still calls history.replace and is not affected.

What a learner sees

After arriving with ?start_course=1, the history holds two entries for the course home: the address with the parameter, and the one without. Back goes to the first. The effect runs again there, sends enrollment.email.clicked.startcourse again and adds the clean address again. Each press of Back repeats that, so Back does not leave the page and the event is counted once per press.

Fix

navigate({ pathname, search }, { replace: true }), with a case that fails when the cleanup adds an entry. #2252 does this in the frontend-base package: its case asserts that the router's last navigation was a replace, and it fails with the call as it is here, the router reporting a push.

Acceptance

  • After arriving with ?start_course=1, Back leaves the course home
  • enrollment.email.clicked.startcourse is sent once
  • A test fails if the cleanup adds a history entry
Dominant language
JavaScript
Stars
71
Forks
341
Avg merge
4d 18h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openedx/frontend-app-learning

All issues in openedx/frontend-app-learning

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.