ember.js: [Glimmer] Nested components no longer have access to their parent?
I recently tried upgrading ivy-tabs to Ember 1.13 and ran into some issues around changes to parentView in components. Prior to 1.13, a nested component could access its outer component through parentView. I was using this in ivy-tabs to register an ivy-tab component with the ivy-tab-list that contained it, among other things:
{{#ivy-tab-list}}
{{#ivy-tab}}Tab 1{{/ivy-tab}}
{{#ivy-tab}}Tab 2{{/ivy-tab}}
...
{{/ivy-tab-list}}
It seems that with the 1.13 upgrade, parentView is now always the “routable” view that rendered the component, and I don’t see a way for components to access each other at all. Is my example an intended use case? If not, is there some other way to do what I want?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 15 (11 by maintainers)
Given the relatively large number of addons that are affected by this, I think we should attempt to match the 1.12 semantics with
this.get('parentView')from within a component.Given the initial example:
Inside the
{{ivy-tab}}instances, callingthis.get('parentView')should return the instance of{{ivy-tab-list}}.Even though we should definitely fix this issue, I do believe that the better pattern would be to use block params and provide each
{{ivy-tab}}instance with its parent. So the above example would become:Yes, I realize that may not be as aesthetically pleasing but it is easier to reason about. In the long run, I think the following is the best API:
It allows the
ivy-tabchild component to be completely scoped to its parent (without the manual wiring oflist=list), and is still quite declarative. This syntax will be unlocked by https://github.com/emberjs/ember.js/pull/10244 once I have time to work on it again.tldr; I think we should deprecate accessing
parentViewand suggest using block params.