-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Glimmer removes ability to access childViews from a component #11244
Comments
Would be great to have a JSBin demo (I am disputing your statement though). |
@runspired a jsbin would help us know if this is directly related to #11170 or not. |
@mixonic it's not a ContainerView, so not sure it's related to that. It actually was a containerView until yesterday, but I reworked it (on 1.12) to be components and then moved to try out Glimmer and found this issue. I'll whip up a JSBin. |
Working in 1.12 Code: https://github.com/runspired/smoke-and-mirrors/blob/master/addon/components/occlusion-collection.js#L417-L441 Broken in Glimmer: Working in 1.12: |
And yes, I know this was a private API, but it was a private API I've seen many have need for. I don't condone registering children this way for composable components, but in this case the children are children generated by the parent component. |
A few alternatives for your scenario:
I think I like the latter better (it would be possible to use this in 1.12 with |
@rwjblue the alternative I've implemented is to pass |
The key and difficult thing is maintaining an accurate order, so I need to mirror changes to the array to changes in the generated childViews array. |
In 1.13+ you could reset the array in the parents |
I take it |
Answered my own question, it should: #10501 I think this is closable as the |
I also think it is easier to understand even for folks new to Ember (since it is much more declarative about what is going on) and has a dramatic lack of magical private APIs. 😺 |
This also breaks http://stackoverflow.com/a/14328909/4737452 how can we implement this now in a easy way? I'm not sure how I can register the link-to helper / view in my component.. |
Having the same problem as @topaxi here. +1 |
@timohofmeijer I solved it by using the following, imho weird, solution:
const { computed } = Ember
Ember.LinkView.reopen({
activeLink: computed({
set(key, value) {
value.set('linkView', this)
}
})
})
export default Ember.Component.extend({
tagName: 'li',
classNames: [ 'active-link' ],
classNameBindings: [ 'active' ],
active: computed.alias('linkView.active'),
linkView: null
})
{{yield this}} Now I can use it like this: {{#active-link as |link|}}
{{#link-to 'login' activeLink=link}}Login{{/link-to}}
{{/active-link}} I'm not sure if this is an acceptable solution though... |
Looks pretty good to me @topaxi. Thanks for sharing. The thing with me is, I need the wrapper to get an active state when any of the nested |
@timohofmeijer Can you share your solution? I was using childViews to mark menu items active on a navigation dropdown (e.g bootstrap navbar). With childViews not able to be observed tree type navigation structures are a bit difficult to work with now. |
Basically a wrapper component with an active classBinding which observes route changes and then looks for
It’s a port from Alex Speller’s pre Within this repo’s issues, perhaps a more versatile solution is offered by @rwjblue: good luck @Kilowhisky |
I ended up with a modified version of what @topaxi did. I turned
|
These seem like very complex and convoluted solutions to a problem that should be real simple to manage. Why is the framework fighting something like this: <nav role="navigation>
<ul class="site-nav">
{{#link-to "index" tagName="li" as |link|}}
<button class="btn btn-default {{if link.active 'active'}}">Index</button>
{{/link-to}}
{{#link-to "route1" tagName="li" as |link|}}
<button class="btn btn-default {{if link.active 'active'}}">Route 1</button>
{{/link-to}}
{{#link-to "about" tagName="li" as |link|}}
<button class="btn btn-default {{if link.active 'active'}}">about</button>
{{/link-to}}
</ul>
</nav> You could attempt this: {{#link-to "about" tagName="li"}}
<button class="btn btn-default {{if childViews.firstObject.active 'active'}}">about</button>
{{/link-to}} But that seems weird and not supported. Is it really the intent to make
|
_childViews
no longer exists andchildViews
is never populated. This makes it very difficult to build components that need ordered access to their child views.The text was updated successfully, but these errors were encountered: