A developer, merefield, encountered a TypeError: this.parentMountWidgetComponent is undefined error while attempting to render a Glimmer Component as a widget in the Poll plugin. The issue arose because this._findAncestorWithProperty("_emberView") failed to find a parent widget with the required property, due to the widget’s ancestry being lost during transitions. merefield traced the problem to the widget hierarchy not being properly maintained and the rerenderWidget() method not being called. david identified that the issue was due to the poll widget being mounted inside post HTML rather than via <MountWidget>, and proposed a fix in a pull request (#26675). merefield confirmed the fix resolved the issue, though the solution is temporary as the team plans to phase out the current widget system.
I’m attempting to render a Glimmer Component as a widget tree leaf as I’ve done several times before, but getting this strange error I’ve not seen before:
TypeError: this.parentMountWidgetComponent is undefined
firing on this line:
It seems that this.widget?._findView() || this._emberView
I’m guessing the ancestor should have had it set here:
OK a bit more info.
When the Poll is rendered (as a tree of widgets), this line is executed, but when you transitiion back to vote, it is not, thus for some reason there is no ancestor with an “_emberView” (Or it is not being found)
The source of this problem might be that the widget is never re-rendered:
rerenderWidget() {
Is not fired again despite adding a new tree of widgets … so this property is never set.
… thus the solution to this might be scheduling a re-render when the Vote button is hit …
The poll plugin is a little unusual in that the widget is mounted inside a post’s cooked HTML, rather than directly inside an Ember template via the <MountWidget component. So we probably need to add some extra logic here… will take a look
It’s not particularly pretty, but I think it’s ok since this is a pretty rare situation, and we hope to totally rip out all this widget/RenderGlimmer stuff in the not-too-distant future