docs: fix FRONTEND_SLOTS slot operation example - #325
Open
arbrandes wants to merge 1 commit into
Open
Conversation
The op field takes WidgetOperationTypes constants, not string literals, which fail the type check in customApp.tsx. Also, relatedId must match the widget id the shell appends to the footer slot. Co-Authored-By: Claude <noreply@anthropic.com>
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
The
FRONTEND_SLOTSexample in the README doesn't work as documented. Itsopfield used a plain string literal, butopis typed as a TypeScript enum in frontend-base, soop: 'widgetReplace'fails the type check whencustomApp.tsxis built. The example now importsWidgetOperationTypesthrough themfe-site-custom-app-importspatch and usesWidgetOperationTypes.REPLACE. The paragraph claiming the string values were equivalent, and not worth an import, is gone.The example's
relatedId: 'defaultContent'was also wrong. In frontend-base,defaultContentis the id of the widget synthesized from a slot's JSX children, but the shell renders the footer slot without children and fills it by appending a widget with the idorg.openedx.frontend.widget.footer.main.v1. ArelatedIdthat matches nothing is silently ignored, so the documented operation had no effect at all. The example now targets that widget id.Finally, the list of available operations names the enum constants instead of their underlying string values, so it matches what a plugin author actually has to write.
LLM usage notice
Built with assistance from Claude.