Skip to content

fix: Sync pagination state after course data fetch#3065

Open
HamzaIsrar12 wants to merge 1 commit into
openedx:masterfrom
edly-io:hamza/fix-pagination-state-sync-on-fetch
Open

fix: Sync pagination state after course data fetch#3065
HamzaIsrar12 wants to merge 1 commit into
openedx:masterfrom
edly-io:hamza/fix-pagination-state-sync-on-fetch

Conversation

@HamzaIsrar12
Copy link
Copy Markdown

@HamzaIsrar12 HamzaIsrar12 commented May 19, 2026

Description

Edly-8271

When a user navigates to page 2+ on the Studio course listing page and then navigates away (via browser back button or clicking the Studio logo), returning to the listing page loads page 1 content correctly but the pagination UI still highlights the previously selected page number. This creates a mismatch between the displayed content and the active pagination indicator.

Root cause: The fetchStudioHomeData thunk fetches courses for a specific page but never syncs currentPage in the Redux store after a successful fetch. The currentPage was only being updated manually in handlePageSelected (on user click), but not when courses were fetched on component mount or other triggers.

Fix: After successfully fetching course data in the thunk, dispatch updateStudioHomeCoursesCustomParams({ currentPage: requestParams.page || 1 }) to keep the pagination UI state in sync with the actually fetched page.

Impacted user role: Course Author

Supporting information

This bug is reproducible on any Studio instance with enough courses to trigger pagination (more than one page).

Testing instructions

  1. Log in to Studio and navigate to the course listing page (/home). Ensure there are enough courses to have multiple pages.
  2. Click page 2 (or any page beyond 1) in the pagination control.
  3. Verify page 2 content loads and page 2 is highlighted in the pagination bar.
  4. Either click the browser back button or click the Studio logo to return to the listing page.
  5. Expected: Both the content and the pagination indicator should show page 1.
  6. Before fix: Page 1 content loads but the pagination bar still highlights the previously selected page.

Other information

  • This change does not depend on other changes elsewhere.
  • No deprecations, migrations, security, or accessibility concerns.
  • The fix is a single dispatch call added to the existing thunk, minimal surface area for side effects.

Best Practices Checklist

  • Any new files are using TypeScript (.ts, .tsx). (No new files added)
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components. (This fix updates an existing Redux field, not adding new state. Ideally this should be migrated to React Context in the future, but that's a larger refactor.)
  • Use React Query to load data from REST APIs. (The existing thunk pattern is maintained; migrating to React Query is tracked as a TODO in the codebase.)
  • All new i18n messages in messages.ts files have a description for translators to use. (No new messages)
  • Avoid using ../ in import paths.

Update currentPage in Redux after fetching courses
in the thunk so the pagination UI stays in sync
with the fetched page content on navigation.

Fixes: Edly-8271
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels May 19, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @HamzaIsrar12!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.55%. Comparing base (36d42b0) to head (24ed4bc).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3065   +/-   ##
=======================================
  Coverage   95.55%   95.55%           
=======================================
  Files        1393     1393           
  Lines       32992    32993    +1     
  Branches     7644     7646    +2     
=======================================
+ Hits        31524    31525    +1     
+ Misses       1413     1401   -12     
- Partials       55       67   +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions May 20, 2026
@UsamaSadiq UsamaSadiq requested a review from Copilot May 21, 2026 07:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a pagination UI/state mismatch on the Studio course listing page by ensuring Redux pagination state is updated after course data is fetched, not only on explicit user pagination clicks.

Changes:

  • Import updateStudioHomeCoursesCustomParams into the studio-home thunk module.
  • Dispatch updateStudioHomeCoursesCustomParams({ currentPage: ... }) after a successful getStudioHomeCoursesV2 fetch to sync the active pagination state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 45 to 48
const coursesData = await getStudioHomeCoursesV2(search || '', requestParams);
dispatch(fetchCourseDataSuccessV2(coursesData));
dispatch(updateStudioHomeCoursesCustomParams({ currentPage: requestParams.page || 1 }));
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.SUCCESSFUL }));
Comment on lines 45 to 48
const coursesData = await getStudioHomeCoursesV2(search || '', requestParams);
dispatch(fetchCourseDataSuccessV2(coursesData));
dispatch(updateStudioHomeCoursesCustomParams({ currentPage: requestParams.page || 1 }));
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.SUCCESSFUL }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

4 participants