Skip to content

fix: restore add-component buttons for content experiment groups - #38997

Merged
AhtishamShahid merged 1 commit into
openedx:masterfrom
mitodl:anas/fix-content-experiment-add-components
Aug 18, 2026
Merged

fix: restore add-component buttons for content experiment groups#38997
AhtishamShahid merged 1 commit into
openedx:masterfrom
mitodl:anas/fix-content-experiment-add-components

Conversation

@Anas12091101

Copy link
Copy Markdown
Contributor

Description

Content experiments (split_test) render no Add New Component panels in the authoring MFE, so Course Authors cannot add content to experiment groups at all. Regression from #38636, which narrowed the guard in renderAddXBlockComponents() to canEdit && !isIframeEmbed — correct for units and problem banks, which the MFE renders natively, but the MFE renders no add buttons for split_test (AddComponent only renders its button list for unit verticals). Each group needs its own panel beside its own children, which only the container page can place.

This restores isSplitTestContentPage to the guard, as it was before 3c5cc6fffd. Deliberately narrower than reverting to !model.isVertical(), so problem banks stay on MFE-native rendering.

The rest of the flow was already iframe-aware and dead since the regression: createComponent() posts addNewComponent/hideProcessingNotification to the parent for split_test, add_xblock.js keeps template menus in the iframe when the parent is split_test, and frontend-app-authoring already handles both messages. Nothing changes server-side — the vertical author view always renders group children with can_add=True, so the panels were in the fragment and only JS removed them. No frontend-app-authoring change is required.

Before After
split-test-before split-test-after

Supporting information

Testing instructions

Requires the new unit page (legacy_studio.unit_editor disabled — the default) and an asset rebuild, since container.js is bundled into the js/factories/container webpack entry:

npm run build-dev     # or `npm run webpack-dev`; Tutor: tutor dev exec cms npm run webpack-dev

Set up an experiment, if the course has none:

  1. Settings → Advanced Settings → add "split_test" to Advanced Module List.
  2. Settings → Group Configurations → create an Experiment Group Configuration with two groups.
  3. In a unit: Add Component → Advanced → Content Experiment.

Verify the fix:

  1. From the unit page, click into the Content Experiment to reach /course/<course-id>/container/<split_test-id>/<subsection-id>.
  2. Each group shows an Add New Component panel. (Before this change: no panels.)
  3. Click Text in Group A, pick a template → the MFE shows its "Adding…" spinner and the component appears inside Group A. Repeat in Group B and confirm it lands in B. Reload; both persist.
  4. Click Problem → the template submenu renders inside the iframe, not as an MFE modal.
  5. With v2 libraries enabled, Library Content → the picker opens as an MFE modal over the iframe.

Verify nothing else changed:

  1. A normal unit → only the MFE's native add row; no duplicate legacy buttons in the iframe.
  2. A Problem Bank container page → still MFE-native buttons only.
  3. The legacy container page, /container/<split_test-id> → unchanged (never took the regressed branch).

Note on hard-refreshing: the iframe is a separate cross-origin document and dev builds emit an unhashed container.js, so reload the frame itself or use "Disable cache" — a hard reload of the outer page can leave the old bundle in place.

Automated tests: adds two specs to container_spec.js covering both branches. They have not been executedkarma_cms_webpack.conf.js fails to start (ENOENT ... main_webpack.<hash>.js, #35956) and npm run test-karma skips that suite for the same reason. Verification was manual in Chrome, both directions: regressed bundle → 0 panels / 0 buttons; fixed → 2 panels / 16 buttons; adding a component writes it under the clicked group in the modulestore.

Deadline

None

Other information

No dependent PRs, no MFE change, no migrations, no new settings. Limitation: this keeps the legacy per-group add widgets alive for content experiments; removing the legacy unit editor (#35261) will need per-group add UI rendered natively by the MFE.

@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @Anas12091101!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform-oncall.

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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 17, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Aug 17, 2026
@AhtishamShahid

Copy link
Copy Markdown
Contributor

Tested manually and confirmed the fix works as described.

Environment: Tutor dev (Python 3.12 image, current master baseline), split_test enabled in Advanced Module List, one Experiment Group Configuration (Group A / Group B) added to a course, rebuilt CMS webpack (npm run webpack-dev) to pick up container.js.

  • Content Experiment container page now shows a separate Add New Component panel under both Group A and Group B (pre-fix: zero panels — confirmed by reverting to the parent commit and rebuilding).
  • Added a Text component via Group A's panel and a Problem via Group B's panel — each template menu rendered inline in the iframe, not as an MFE modal.
  • Reloaded the page — both components persisted (written to the modulestore, not just client-side render) and stayed scoped to their own group only.
  • Regression check: a normal (non-split_test) unit still shows a single native MFE "Add a new component" row, no duplicate/legacy buttons.

@AhtishamShahid
AhtishamShahid merged commit 36396d7 into openedx:master Aug 18, 2026
42 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions Aug 18, 2026
@AhtishamShahid
AhtishamShahid deleted the anas/fix-content-experiment-add-components branch August 18, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants