Skip to content

Reading a slot by ID from inside another slot picks up that slot's children #364

Description

@arbrandes

Description

The hooks that read a slot by its ID (useWidgetsForId, useWidgetOperations, useWidgetOptionsForId) all go through useSlotOperations(id). That function takes children and idAliases from the slot context, which is the context of whatever slot encloses the caller, and never checks that it's the slot being asked about.

In other words: when code inside slot A asks about slot B, slot A's children come back as slot B's defaultContent widget, and slot A's aliases are treated as slot B's.

Learning ran into this in openedx/frontend-app-learning#2267. Its sidebar provider has to decide which panel opens before the sidebar slots render, so it reads the panel slot from above it, much like the shell's own dropdown menu does. That read happens inside the courseware tab's slot. The slot has no children today, so nothing breaks, but a site that renders the courseware in a slot of its own, with children, would get a phantom widget in the sidebar's list. Learning filters defaultContent out by ID to be safe.

What I'd expect instead: the enclosing slot's children and aliases apply only when it's the slot being asked for. Read from outside, a slot has no default content, since that only exists where the slot is rendered.

Activity

  1. added a commit that references this issue on Nov 26, 2026
    8e97681
  2. self-assigned this
    on Nov 26, 2026
  3. moved this to In Progress in frontend-baseon Nov 26, 2026
  4. moved this from In Progress to In Review in frontend-baseon Nov 26, 2026
  5. added theissue type on Nov 26, 2026
  6. openedx-semantic-release-bot commented on Nov 26, 2026

    @openedx-semantic-release-bot

    🎉 This issue has been resolved in version 2.0.0-alpha.20 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions