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

HELP: Ember 2.8 -> Using oberver on property that has computed.alias of parentView property #14337

Closed
deverin opened this issue Sep 23, 2016 · 10 comments

Comments

@deverin
Copy link

deverin commented Sep 23, 2016

Using property like this inside nested component to observe parent components property which is boolean

expandMenu: Ember.computed.alias 'parentView.expandMenu'

This esentially creates error

ember.debug.js:6778 Uncaught Error: Assertion Failed: You must use Ember.set() 
to set the `parentView` property (of <appname@component:simple-menu::ember690>) 
to `<appname@component:simple-menu-container::ember662>`.

simple-menu-container - is parent
simple-menu - is child -> expandMenu property is here

Came in with Ember 2.8, 2.7.3 works just fine

This issue
piceaTech/ember-rapid-forms/issues/134
resolves similar but different issues.

I am doing something wrong or something needs fixing?

You might think that this is the same error that was fixed in Ember 2.8.1, but please pay close attention. Fix was introduced here #14281

2.8.1 fixes problem with setting parentView to null

This error IS fixed with 2.8.1:

 Uncaught Error: Assertion Failed: You must use Ember.set() to set the `parentView` property (of 
 <myapp@component:em-input::ember619>) to `null`

This error IS NOT fixed with 2.8.1

Uncaught  Error: Assertion Failed: You must use Ember.set() to set  `parentView` 
property (of <appname@component:simple-menu::ember690>) to 
`<appname@component:simple-menu-container::ember662>`.

It wants me to set parentView property inside nested component to its parentComponent under which it is nested.

Problem starts when I am using an .observer('expandMenu') or any observer that observes property where parentView is involved


ember: 2.8.1

ember -v -verbose

ember-cli: 2.8.0
http_parser: 2.7.0
node: 6.6.0
v8: 5.1.281.83
uv: 1.9.1
zlib: 1.2.8
ares: 1.10.1-DEV
icu: 57.1
modules: 48
openssl: 1.0.2h
os: darwin x64
@rwjblue
Copy link
Member

rwjblue commented Sep 23, 2016

Can you please provide a reproduction twiddle or repo for this? I'm not sure where parentView is being set outside of the situation that is fixed in 2.8.1...

@Serabe
Copy link
Member

Serabe commented Sep 23, 2016

Cannot reproduce this in 2.8.1 (twiddle), can you please provide a reproduction?

Thank you!

@deverin
Copy link
Author

deverin commented Sep 26, 2016

In progress, will post update

@deverin
Copy link
Author

deverin commented Sep 26, 2016

Here is a reproduction

twiddle

@deverin
Copy link
Author

deverin commented Sep 28, 2016

Is there any news?

@pixelhandler
Copy link
Contributor

@dimul regarding parentView, see http://emberjs.com/api/classes/Ember.View.html#property_parentView this is a private property on a deprecated object. The component guides and api docs do not recommend using parentView. Perhaps there is another approach altogether.

@deverin
Copy link
Author

deverin commented Oct 4, 2016

Perhaps there is another approach altogether.

Any suggestions

@Serabe
Copy link
Member

Serabe commented Oct 16, 2016

Passing a property from the parent component to the child component. You can explicitly yield the property or create contextual components for that. See this example with contextual components

@pixelhandler
Copy link
Contributor

@dimul so far it appears this issue is more question or support related, I think you're get more feedback and help in the ember community slack, erhaps reach out in the http://embercommunity.slack.com #-help channel.

@workmanw
Copy link

I'm not sure I agree that this is a support issue. I think it's clearly usage of an intimate API that worked in one version of Ember and does not work in a more current version. While using an "Intimate API" can be controversial, I think you'll find more people with older apps who use parentView. There was certainly a simpler time where using parentView was an accepted solution to many problems. We certainly had cases where we were using parentView that was broken by this change.

In our case it was easy to move off of parentView and just pass the reference to the component instance as an attribute. But I do think it's sensible to at least acknowledge that this use to be supported and now for complicated technical reasons it is no longer practical to do so.

@locks locks closed this as completed Oct 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants