Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save grapho/dc66d9f6842e7a1f142e8a946e1109d5 to your computer and use it in GitHub Desktop.
Save grapho/dc66d9f6842e7a1f142e8a946e1109d5 to your computer and use it in GitHub Desktop.
Yet another Query Params bug #14438
import Ember from 'ember';
export default Ember.Route.extend({
model () {
return new Em.RSVP.Promise(setTimeout)
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['foo', 'bar'],
foo: 'FOO',
bar: 'BAR'
});
<p>
This issue has been reported as <a href="https://github.com/emberjs/ember.js/issues/14438">#14438</a>.
</p>
<img style="float: right; width: 150px; height: 150px; margin: 0 0 1rem 1rem;" src="http://i.imgur.com/8tDKnZk.png" alt="impossiburu">
<p>
Type into both fields and see how query params reset each other:
</p>
<p>
{{input value=foo}}
{{input value=bar}}
</p>
<p>
Here are the minimal prerequisites to reproduce this issue:
</p>
<ul>
<li>There are three nested routes involved: <code>grandparent.parent.child</code>, but not all of them have to be defined.</li>
<li>The <code>parent</code> controller must have a query param (<code>foo</code>).</li>
<li>There must be another query param (<code>bar</code>): either in the same route or the child route.</li>
<li>
Updating <code>bar</code> causes <code>foo</code> to reset to its default value!</li>
<li>The child route's model hook must return a pending promise.</li>
<li>There must be a loading template on the child level: <code>grandparent.parent.loading</code>. At the same time, the <code>&#123;&#123;outlet}}</code> in the <code>parent</code> route is not required!</li>
<li>The <code>grandparent</code> route must have a dynamic segment.</li>
</ul>
<p>
Remove any of these prerequisites and the bug won't manifestate.
</p>
{{outlet}}
import Ember from 'ember';
export default Ember.Route.extend({
redirect() {
this.transitionTo('grandparent.parent.child', 1);
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('grandparent', {path: 'grandparent/:bax'}, function () {
this.route('parent', function () {
this.route('child');
});
});
});
export default Router;
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
{
"version": "0.10.5",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.8.0",
"ember-data": "2.8.0",
"ember-template-compiler": "2.8.0",
"ember-testing": "2.8.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment