Skip to content

feat: slot layouts over wrapping operations#196

Open
arbrandes wants to merge 3 commits intoopenedx:mainfrom
arbrandes:no-slot-wrapping-operation
Open

feat: slot layouts over wrapping operations#196
arbrandes wants to merge 3 commits intoopenedx:mainfrom
arbrandes:no-slot-wrapping-operation

Conversation

@arbrandes
Copy link
Contributor

@arbrandes arbrandes commented Mar 19, 2026

Description

Adds an ADR documenting the decision to not implement a widget wrapping operation in frontend-base. The legacy @openedx/frontend-plugin-framework provided a Wrap operation, used notably by frontend-plugin-aspects to toggle sidebar visibility. The ADR explains why the existing layout system is the architecturally preferred alternative, and why a wrapping operation is fundamentally at odds with the slot/layout/widget pipeline.

As part of this decision, useWidgets() is enriched with identity-based filtering helpers (byId(), withoutId(), byRole(), withoutRole()). These methods let layouts selectively render widgets without breaking backwards compatibility — the returned array still renders identically when used as-is. Internally, the widget metadata (ID and role) that was previously stripped before reaching layouts is now preserved and exposed through these helpers.

The slot showcase gains a new demo showing widgets.byRole() in action: a layout that toggles between all widgets and only those with a "highlighted" role. Two existing showcase options that were passing JSX elements instead of plain strings are also fixed.

LLM usage notice

Built with assistance from Claude models (mostly Opus 4.6).

@arbrandes
Copy link
Contributor Author

@jsnwesson and @MaxFrank13, would love your thoughts on this, as I suspect you might actually use FPF's wrap operation.

Copy link
Contributor

@holaontiveros holaontiveros left a comment

Choose a reason for hiding this comment

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

It makes a lot of sense, I still haven't seen in depth the old system I just check a couple of things on how it worked before so given that many thigns will need to be fully migrated to be compatible with frontend-base maybe we should have some links to some succesful migrations after they start appearing, so everyone can do it easily.

I does look straighforward but depending on how the people look at it some example to wrap their head saround it may be helpful

@arbrandes
Copy link
Contributor Author

@holaontiveros

maybe we should have some links to some succesful migrations after they start appearing, so everyone can do it easily.

Totally. I originally thought about converting frontend-plugin-aspects itself, but unfortunately it targets slots in frontend-app-authoring, which is the last one on the list to be converted to frontend-base.

We'll figure something out in the docs.

Document the decision to not implement a widget wrapping operation in
frontend-base, recommending layout replacements as the architecturally
preferred alternative.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@arbrandes arbrandes force-pushed the no-slot-wrapping-operation branch from 623af19 to 68c7401 Compare March 19, 2026 23:41
arbrandes and others added 2 commits March 19, 2026 20:53
Expose byId(), withoutId(), byRole(), and withoutRole() methods on the
array returned by useWidgets(), enabling layouts to selectively render
widgets by identity without breaking backwards compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a ToggleByRoleLayout demo that uses the new widgets.byRole()
helper to toggle between all widgets and only those with a highlighted
role.

Also fix two options values in the showcase that were passing JSX
elements instead of plain strings, causing the options to be ignored
by the type checks in their respective layouts.

Remove outdated wrapping reference from the showcase intro text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@arbrandes arbrandes changed the title docs: ADR for slot layouts over wrapping operations feat: slot layouts over wrapping operations Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants