Skip to content

fix: showUserDropdown hiding LearningHeaderActionsSlot#676

Open
tecoholic wants to merge 1 commit into
openedx:masterfrom
open-craft:tecoholic/sort-out-learning-header-slots
Open

fix: showUserDropdown hiding LearningHeaderActionsSlot#676
tecoholic wants to merge 1 commit into
openedx:masterfrom
open-craft:tecoholic/sort-out-learning-header-slots

Conversation

@tecoholic

@tecoholic tecoholic commented Jul 24, 2026

Copy link
Copy Markdown

Description

The showUserDropdown prop gates both the LearningHeaderActionsSlot and the AuthenticatedUserDropdown. This makes it impossible to just hide the userDropdown without also hiding all the action items like the help menu and the notifications.

This commit applies the showUserDropdown gate to just the user dropdown menu.

Reference

#675

Before

image

After

image

Testing instructions

Important

Before starting, ensure you have a Tutor environment with the Learning MFE in development mode running.

  1. Clone the repo. From the main branch and run npm ci && npm run build
  2. From the Learning MFE run npm install "../path/to/this/repo" --legacy-peer-deps
  3. Add the following to frontend-app-learning/env.config.jsx
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';

const hideUserMenu = ({ widget }) => {
  widget.content = {
    ...widget.content,
    showUserDropdown: false,
  };
  return widget;
};

export default {
  pluginSlots: {
    'org.openedx.frontend.layout.header_learning.v1': {
      keepDefault: true,
      plugins: [
      {
        op: PLUGIN_OPERATIONS.Modify,
        widgetId: 'default_contents',
        fn: hideUserMenu,
      }
    ]
  },
  }
};
  1. Add the following to frontend-app-learning/module.config.js
module.exports = {
  localModules: [
    {
      moduleName: '@edx/frontend-component-header',
      dir: '../frontend-component-header' // adjust this relative to your repo
    }
  ]
};
  1. Run the Learning MFE in dev mode and see that the Notifications dropdown and the "Help" action item have disappeared from the header along with the user dropdown.
  2. Go the frontend-component-header repo and switch to this PR's branch.
  3. Run npm run build (a couple of times for luck, I found webpack missing references as it live reloads)
  4. Now go back to the Learning MFE and verify that the Notifications dropdown and the "Help" action item have returned.

The showUserDropdown prop gates both the LearningHeaderActionsSlot
and the AuthenticatedUserDropdown. This makes it impossible to just
hide the userDropdown without also hiding all the action items like
the help menu and the notifications.

This commit applies the `showUserDropdown` gate to just the user
dropdown menu.

Ref: openedx#675
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 24, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @tecoholic!

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

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

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.18%. Comparing base (e380431) to head (b0c3d74).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #676      +/-   ##
==========================================
+ Coverage   73.07%   73.18%   +0.10%     
==========================================
  Files          60       60              
  Lines         520      522       +2     
  Branches      110      112       +2     
==========================================
+ Hits          380      382       +2     
  Misses        137      137              
  Partials        3        3              

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

@tecoholic
tecoholic requested a review from xitij2000 July 24, 2026 06:56

@xitij2000 xitij2000 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This change generally makes sense to me since it allows using the slot even if showUserDropdown is false. However, my concern is that this changes the nature of the slot.

My recommendation would be making a v2 version of this slot that wraps the v1 version of the slot. So the v2 version of the slot can be rendered in all situations, and get showUserDropdown as a prop. The v2 slot can conditionally render the v1 slot when showUserDropdown and authenticatedUser are truthy. This keeps backwards compatibility while also allowing our use case.

CC: @brian-smith-tcril I'd love your input for how to handle cases like these. Does my suggestion above make sense or is it overkill in this case?

@tecoholic

Copy link
Copy Markdown
Author

@xitij2000

However, my concern is that this changes the nature of the slot.

Do you mean, it changes the current nature of the slot? Because it doesn't change the "nature of the slot" - it still renders action items. I think the current behavior is bugged. showUserDropdown should only affect the dropdown and not the header's action items.

However, I can see the merit of using a V2 to document the change in behavior. Let's see what @brian-smith-tcril thinks as well.

@xitij2000

Copy link
Copy Markdown

@xitij2000

However, my concern is that this changes the nature of the slot.

Do you mean, it changes the current nature of the slot? Because it doesn't change the "nature of the slot" - it still renders action items. I think the current behavior is bugged. showUserDropdown should only affect the dropdown and not the header's action items.

However, I can see the merit of using a V2 to document the change in behavior. Let's see what @brian-smith-tcril thinks as well.

What I mean to say is that it goes from being a conditional slot to a permanent slot. Plugins might be relying on the fact that this slot is rendered conditionally, and they will need to change their code.

@brian-smith-tcril

Copy link
Copy Markdown
Contributor

Multiple things going on here:

  • Currently both LearningHeaderActionsSlot and AuthenticatedUserDropdown are gated behind both showUserDropdown and authenticatedUser
  • LearningHeaderActionsSlot renders both HeaderNotificationsSlot and LearningHelpSlot by default

With that in mind, the change in this PR would be breaking the existing slot API contract and should not land as-is.

If we want to continue gating both LearningHeaderActionsSlot and AuthenticatedUserDropdown on authenticatedUser that makes the v2 solution decently straightforward - it could be something like

- const LearningHeaderActionsSlot = () => (
+ const LearningHeaderActionsSlot = (showUserDropdown) => (
  <PluginSlot
-    id="org.openedx.frontend.layout.learning_header_actions.v1"
+    id="org.openedx.frontend.layout.learning_header_actions.v2"
  >
+    {showUserDropdown && (
+       <PluginSlot
+         id="org.openedx.frontend.layout.learning_header_actions.v1"
+       >
          <HeaderNotificationsSlot />
          <LearningHelpSlot />
+       </PluginSlot>
+     )}
  </PluginSlot>
);

I do want to consider if gating behind authenticatedUser is also desired behavior. If it isn't it'd be better to change that in a v2 than need to make a v3.

I would also recommend putting out a DEPR for the v1 version of the slot as the current behavior does seem to be unintended. We can then have 1 release with overlap (both v1 and v2), and then drop v1.

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: Needs Triage

Development

Successfully merging this pull request may close these issues.

4 participants