Repository navigation
fix: ignore the enclosing slot when reading another slot by id - #365
Merged
arbrandes merged 1 commit intoNov 26, 2026
Merged
Conversation
Hooks that read a slot by id no longer pick up the default content and aliases of whatever slot encloses the caller. Fixes openedx#364. Co-Authored-By: Claude <noreply@anthropic.com>
|
🎉 This PR is included in version 2.0.0-alpha.20 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This fixes #364. Hooks that read a slot by ID, like
useWidgetsForId,useWidgetOperationsanduseWidgetOptionsForId, all go throughuseSlotOperations, which tookchildrenandidAliasesfrom the slot context. That context belongs to whatever slot encloses the caller, not necessarily the slot being asked about. So reading slot B from inside slot A gave you slot A's children as B'sdefaultContentwidget, plus anything registered under A's aliases.Now the enclosing slot's children and aliases only apply when its ID matches the one being asked for. A slot read from outside has no default content and no aliases, which is how it should be: those only exist where the slot is rendered. It's an exact ID match, not one that also accepts the enclosing slot's aliases, since every caller that means "my own slot" already passes the slot's own ID.
None of the callers in
shell/andruntime/relied on the old behaviour.NavDropdownMenuSlotreads its slot by ID from insideheader.primaryLinks.v1, which has no children or aliases, so its output doesn't change. The new tests inruntime/slots/hooks.test.tsxcover reading both the enclosing slot and a different one.LLM usage notice
Built with assistance from Claude.