Skip to content

fix: repair the image gallery sort control [backport to verawood] - #3220

Open
ihor-romaniuk wants to merge 2 commits into
openedx:release/verawoodfrom
raccoongang:ihor-romaniuk/gallery-sort-menu-verawood
Open

fix: repair the image gallery sort control [backport to verawood]#3220
ihor-romaniuk wants to merge 2 commits into
openedx:release/verawoodfrom
raccoongang:ihor-romaniuk/gallery-sort-menu-verawood

Conversation

@ihor-romaniuk

@ihor-romaniuk ihor-romaniuk commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

The "Add an image" gallery in the rich-text editors has two problems with its sort control.

Its label reads Bynewest — the space between the "By" prefix and the sort option is missing, so every option renders as Byoldest, ByName A-Z and so on. The label now reads "By newest" again.

Opening that control made the whole modal scroll sideways: the menu is wider than the button it hangs from, so it spilled past the modal's right edge and the modal grew a horizontal scrollbar. The menu now stays inside the modal and the scrollbar is gone.

Both apply to the video gallery too, which uses the same control.

Implementation notes
  • The space was a literal JSX text node in SearchSort.jsx. dprint strips those between elements, and it did so in Use "dprint" as a code formatter, replacing eslint #2997 when it replaced eslint — running dprint fmt on the restored literal removes it again. {' '} survives formatting.
  • The existing SearchSort tests already match on By oldest, but that is the accessible name, and the accname algorithm space-joins text across element boundaries, so they read "By oldest" from markup that displays "Byoldest". The new test asserts the rendered text instead.
  • SelectMenu hard-codes placement="bottom-start" and exposes no alignment prop, and its menu is --pgn-size-menu-item-width-base, 19rem, against a toggle of about 9rem. Measured in the running Studio: the menu ran to x=1258 while the modal ended at x=1120, and the modal's scrollWidth exceeded its clientWidth by 138px.
  • The popper wrapper carries the placement inline, so overriding it needs !important. Popper's own transform stays 0,0 here, so the menu simply anchors to the toggle's other edge.

Screenshot/Video

Before After
before-01-label after-01-label
before-02-menu after-02-menu

Testing

  1. In Studio, open any Problem component for editing — for example a Single select.
  2. In the Question toolbar, click the image button. The "Add an image" modal opens.
  3. Expected: the control in the top right reads "By newest". Before this change it read "Bynewest".
  4. Click it to open the sort menu.
  5. Expected: the menu stays inside the modal and no horizontal scrollbar appears along the bottom of the modal. Before this change the menu hung past the modal's right edge and the modal scrolled sideways.
  6. Pick each option in turn — Oldest, Name A-Z, Name Z-A, Shortest, Longest.
  7. Expected: the label reads "By oldest", "By Name A-Z" and so on, and the gallery reorders.
  8. Repeat from a Text component and from a course custom page.
  9. Expected: the same.
  10. Add a Video component to a unit so the video gallery opens.
  11. Expected: the same sort control, also with a space and also contained. Its filter dropdown and the "Show only my videos" switch are unchanged.

Verified locally

Check Result
Sort label in a running Studio "By newest"; the button's text content went from Bynewest to By newest
Menu geometry with the menu open menu 772–1076 against a modal of 320–1120; before the fix 954–1258
Modal overflow scrollWidth - clientWidth went from 138px to 0; no element in the modal reports a horizontal scrollbar
Toggle placed mid-row, as in the video gallery menu 462–766 inside a body of 174–1266, still no overflow
dprint fmt on the restored literal space strips it again; {' '} survives — this is why the fix takes that form
New test red/green fails with Bynewest, passes after; the four existing tests pass either way
jest on SelectionModal, ImageUploadModal, VideoGallery 14 suites, 168 tests
npm run lint, tsc --noEmit clean
Not verified The video gallery was not opened in the browser — adding a Video component creates a block in the course. Its layout was checked by placing the sort toggle mid-row in the image gallery, which is the same component with the same neighbours.

The gallery sort control reads "Bynewest" instead of "By newest". The space
lived in a literal JSX text node, and dprint stripped it in openedx#2997 when it
replaced eslint. An expression container survives formatting.

The existing tests match on the accessible name, which the accname algorithm
space-joins across elements, so they never saw the missing space.
SelectMenu hard-codes a bottom-start placement and its menu is 19rem wide,
so in the image gallery the open menu hung 138px past the modal's right edge
and gave the modal a horizontal scrollbar. Anchor it to the toggle's other
edge instead.
@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 Aug 28, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @ihor-romaniuk!

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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Aug 28, 2026
@ihor-romaniuk ihor-romaniuk self-assigned this Aug 28, 2026
@ihor-romaniuk ihor-romaniuk added the backport PR backports a change from main to a named release. label Aug 28, 2026
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release/verawood@99ca9c9). Learn more about missing BASE report.

Additional details and impacted files
@@                 Coverage Diff                 @@
##             release/verawood    #3220   +/-   ##
===================================================
  Coverage                    ?   95.60%           
===================================================
  Files                       ?     1392           
  Lines                       ?    33140           
  Branches                    ?     7716           
===================================================
  Hits                        ?    31684           
  Misses                      ?     1403           
  Partials                    ?       53           

☔ View full report in Codecov by Harness.
📢 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.

@arbrandes
arbrandes removed their request for review August 28, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport PR backports a change from main to a named release. 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: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants