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

Using a computed property for a Component's isVisible property breaks with Glimmer. #11206

Closed
Kerrick opened this issue May 18, 2015 · 1 comment · Fixed by #11235
Closed
Labels
Milestone

Comments

@Kerrick
Copy link
Contributor

Kerrick commented May 18, 2015

Example JSBins: Ember 1.13.0-beta.1 (broken) | Ember 1.12.0 (working)

Code:

App.ApplicationController = Ember.Controller.extend({
  isExpanded: false,
  actions: {
    toggle: function() {
      this.toggleProperty('isExpanded');
    }
  }
});

App.FooMenuComponent = Ember.Component.extend({
  isVisible: Ember.computed.bool('attrs.is-expanded')
});
<foo-menu is-expanded={{isExpanded}} />
<button {{action "toggle"}}>Toggle FooMenuComponent</button>

I would expect the foo-menu to be hidden when the page loads, as it is in Ember 1.12.0, but it is visible when the page loads. However, toggling the button back and forth does get it back in sync and causes it to start behaving as expected from then on.

@Kerrick
Copy link
Contributor Author

Kerrick commented May 18, 2015

A temporary workaround for those who want this functionality but don't want to leave the beta: switch to an observer. Workaround JSBin

App.FooMenuComponent = Ember.Component.extend({
  // isVisible: Ember.computed.bool('attrs.is-expanded')
  isExpandedChanged: Ember.observer('attrs.is-expanded', function() {
    this.set('isVisible', this.get('attrs.is-expanded'));
  })
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants