-
-
Notifications
You must be signed in to change notification settings - Fork 52
Bug: load correct workflow page on initial render #2677
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see pagination issues with the following steps on "Default Org":
- Go to /
workflows?page=3
- Change sort
- Check network log. Page is reset to 1 but pagination remains 3
I think a simpler fix might be to move fetchWorkflows
to the firstUpdated
callback and switch the changedProperties.has
to changedProperties.get
. I'll do some more testing but this should work:
protected async willUpdate(
changedProperties: PropertyValues<this> & Map<string, unknown>,
) {
if (
changedProperties.get("orderBy") ||
changedProperties.get("filterByCurrentUser") ||
changedProperties.get("filterByScheduled") ||
changedProperties.get("filterBy")
) {
void this.fetchWorkflows({ page: 1 });
}
if (changedProperties.has("filterByCurrentUser")) {
window.sessionStorage.setItem(
FILTER_BY_CURRENT_USER_STORAGE_KEY,
this.filterByCurrentUser.toString(),
);
}
}
protected firstUpdated() {
void this.fetchWorkflows({
page: parsePage(new URLSearchParams(location.search).get("page")) || 1,
});
void this.fetchConfigSearchValues();
}
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I think this works too, but I'd rather kick off the data fetch a little earlier in the component lifecycle: in the future if/when I get fetch caching working, this'll prevent an initial render without data when data is cached. |
Fixes #2676
cc @SuaYoo
Changes
<btrix-pagination>
so that page changes are always reflected in the URLTesting
Tested locally, it seems to work