-
-
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
Query Params replace
doesn't work if refreshModel
is also used
#10577
Comments
I have the same issue. I would like to have {refreshModel:true, replace:true}, in my route's queryParams. |
@machty are you aware of this one? Looks like it hasn't been labelled yet |
Reproduction: https://jsfiddle.net/w3sj0mkt/19/ Back button should not change input value after you have typed in it |
+1 |
I wonder if #10945 is ultimately related to this issue as well. |
Seems to be related to this line:
transition.queryParamsOnly appears to be set to false when refreshing the model, so the replaceUrl variable is not read from the declaration. edit: updated link with reference to original code. |
I am seeing a similar issue when using 'as' and 'replace' together in a queryParam definition. |
Does this issue have any potential solutions? |
Well, the code in question changed quite a bit since I reported that line, so it's possible that this has been fixed in the meantime. |
I am with 2.3.0-beta.1 and it still happens |
Ah, yes, the line just moved a little. Still the same problem, I guess:
|
I've also encountered something I think is related to this bug, at least if @Fryie's hunch is correct. When queryParams are declared as I was implementing a sortable/filterable paged list view with server-side pagination, and where the sort/filter/page state was represented as queryParams. I planned on using Applying the sticky query params methodology from the guides to clear filters/whatnot for subsequent controller activations worked fine, right up until I realized it would be nice to punt the user back to the first page when the filter criteria changed. I implemented the functionality to push the user back to the first page using an observer on the filter criteria, but it got triggered every time the page was changed as well. It turns out the |
Worked around the issue by intercepting the Far from ideal, as this isn't documented to be public API. :/ actions: {
queryParamsDidChange(changed, totalPresent, removed) {
const propertiesRequiringPageReset = ['sortField', 'sortAscending', 'filterName', 'filterValue'];
const propertyDidChange = function(propName) {
return (changed.hasOwnProperty(propName) || removed.hasOwnProperty(propName));
};
// If the page number has changed, we don't want to clobber that
if ((!propertyDidChange('pageNumber')) &&
(propertiesRequiringPageReset.any(propertyDidChange))) {
// One of the properties that will bump the user back to the first page
// has changed. Intercept and modify the args to make the router think
// the pageNumber already changed with everything else. *grimace*
const previousPageNum = totalPresent.pageNumber;
delete changed.pageNumber;
delete totalPresent.pageNumber;
removed.pageNumber = previousPageNum;
}
// Carry on, nothing to see here.
return this._super(...arguments);
}
} |
This bug is still reproducible as of |
Currently working with Ember 1.11.0-beta.4 and noticed that the query param
replace
option doesn't work withrefreshModel
. If therefreshModel
option istrue
then a new history entry will be added. I assume this is due to the fact that the routemodel
hook is refreshed. Is this expected or a bug?Here is a jsbin showing the issue: http://emberjs.jsbin.com/tevemudera/1/edit?html,js,output
But if
refreshModel
is commented out it works: http://emberjs.jsbin.com/tevemudera/2/edit?html,js,outputThe text was updated successfully, but these errors were encountered: