Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Allow RenderGlimmer to be used inside post-cooked-glued widgets #26675

Merged
merged 1 commit into from Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/assets/javascripts/discourse/app/widgets/render-glimmer.js
Expand Up @@ -178,7 +178,21 @@ export default class RenderGlimmer {
}

get parentMountWidgetComponent() {
return this.widget?._findView() || this._emberView;
if (this._emberView) {
return this._emberView;
}
// Work up parent widgets until we find one with a _emberView
// attribute. `.parentWidget` is the normal way to work up the tree,
// but we use `attrs._postCookedWidget` to handle the special case
// of widgets rendered inside post-cooked.
let widget = this.widget;
while (widget) {
const component = widget._emberView;
if (component) {
return component;
}
widget = widget.parentWidget || widget.attrs._postCookedWidget;
}
}
}

Expand Down
Expand Up @@ -120,6 +120,7 @@ function initializePolls(api) {
groupableUserFields: (pollGroupableUserFields || "")
.split("|")
.filter(Boolean),
_postCookedWidget: helper.widget,
};
const glue = new WidgetGlue("discourse-poll", register, attrs);
glue.appendTo(pollNode);
Expand Down