Skip to content

Conversation

@holaontiveros
Copy link
Contributor

fixes #1400

Description

Adds an event handler on the window resize to check if the sidebar isOpen and the size of the viewport is smaller than the sidebar display to hide the sidebar and prevent it from blocking the course view.

This doesn't have any debounce given that the execution only happens when the sidebar is open and the size it's met so the code get's only executed once.

Video

Before the change:

Screen.Recording.2025-05-29.at.12.58.09.p.m.mov

After the change:

Screen.Recording.2025-05-29.at.12.57.27.p.m.mov

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label May 29, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @holaontiveros!

This repository is currently maintained by @openedx/committers-frontend-app-learning.

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.


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.

Copy link

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

Adds a window resize listener to automatically collapse the course outline sidebar when the viewport is narrower than the sidebar breakpoint.

  • Imports useLayoutEffect, debounce, and breakpoints to set up resize-based collapsing
  • Defines a resize handler within a layout effect to trigger handleToggleCollapse when needed
  • Cleans up the listener on unmount
Comments suppressed due to low confidence (3)

src/courseware/course/sidebar/sidebars/course-outline/hooks.jsx:112

  • This resize-based collapse behavior isn't covered by tests; add unit or integration tests to verify the sidebar hides correctly on window resize.
useLayoutEffect(() => {

src/courseware/course/sidebar/sidebars/course-outline/hooks.jsx:5

  • Remove the unused debounce import or apply it in the resize handler, and clean up the unused DEBOUNCE_WAIT constant.
import { debounce } from 'lodash';

src/courseware/course/sidebar/sidebars/course-outline/hooks.jsx:23

  • The DEBOUNCE_WAIT constant is defined but not used; remove it or integrate it with lodash.debounce to regulate the resize handler.
const DEBOUNCE_WAIT = 1; // ms

@codecov
Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.45%. Comparing base (31b02d7) to head (b292e6c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1720      +/-   ##
==========================================
+ Coverage   90.43%   90.45%   +0.01%     
==========================================
  Files         344      344              
  Lines        5793     5802       +9     
  Branches     1394     1398       +4     
==========================================
+ Hits         5239     5248       +9     
  Misses        535      535              
  Partials       19       19              

☔ 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.

@diana-villalvazo-wgu diana-villalvazo-wgu added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label May 30, 2025
@holaontiveros holaontiveros requested a review from a team May 30, 2025 19:25
@holaontiveros holaontiveros added product review PR requires product review before merging and removed product review PR requires product review before merging labels May 30, 2025
Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

I had just noticed this bug when testing another commit - thank you for tackling the problem!

The code looks good in principle, but it doesn't always work. This is one case where it worked:

Success.mp4

Immediately followed by one where it didn't:

Failure.mp4

It seems the actual width the window ends up in may have something to do with it.

This is on Firefox 139.0.1 on Linux, by the way. I wouldn't be completely surprised if this behavior is not reproducible in other browsers/platforms, but I am interested if this is the case.

@holaontiveros
Copy link
Contributor Author

I had just noticed this bug when testing another commit - thank you for tackling the problem!

The code looks good in principle, but it doesn't always work. This is one case where it worked:

Success.mp4
Immediately followed by one where it didn't:

Failure.mp4
It seems the actual width the window ends up in may have something to do with it.

This is on Firefox 139.0.1 on Linux, by the way. I wouldn't be completely surprised if this behavior is not reproducible in other browsers/platforms, but I am interested if this is the case.

It's related with the speed the events are triggered I even didn't debounce it to preven that exact failure in chrome, let me try to fine tune it a bit more so it works also in FF

@holaontiveros
Copy link
Contributor Author

@arbrandes I optimized the code to make sure that it's not toggled the "isOpen" wasn't doing the same there as in Chrome... so I just made sure that the sidebar is properly collapsed and not toggled, the code is still triggered once when the the conditions are met and there's no more flickering.

Screen.Recording.2025-06-04.at.9.36.45.a.m.mov

@arbrandes
Copy link
Contributor

@holaontiveros, thanks for the update! Do you mind rebasing on latest master and resolving conflicts?

@holaontiveros holaontiveros force-pushed the feat/OEXCOM-105-sidebar-resize-hide branch from 54c4820 to b292e6c Compare June 4, 2025 19:13
@holaontiveros
Copy link
Contributor Author

@arbrandes done!

@holaontiveros holaontiveros requested a review from arbrandes June 4, 2025 19:19
Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

This works beautifully! Thank you!

@arbrandes arbrandes merged commit d1dede5 into openedx:master Jun 4, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in Contributions Jun 4, 2025
@holaontiveros holaontiveros deleted the feat/OEXCOM-105-sidebar-resize-hide branch June 4, 2025 20:14
@mariajgrimaldi
Copy link
Member

Thank you so much for working on this, @holaontiveros! Can you help us backporting this fix to the release/teak branch? We'd really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Left-sidebar navigation automatically takes over whole screen when the window is minimized

5 participants