Skip to content

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

Merged
merged 6 commits into from
Jun 23, 2025

Conversation

emma-sg
Copy link
Member

@emma-sg emma-sg commented Jun 18, 2025

Fixes #2676
cc @SuaYoo

Changes

  • Only resets page to 1 when switching filters after initial load
  • Always renders <btrix-pagination> so that page changes are always reflected in the URL

Testing

Tested locally, it seems to work

@emma-sg emma-sg requested a review from tw4l June 18, 2025 17:05
@emma-sg emma-sg requested a review from SuaYoo June 23, 2025 19:21
Copy link
Member

@SuaYoo SuaYoo left a 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":

  1. Go to /workflows?page=3
  2. Change sort
  3. 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();
  }

@emma-sg

This comment was marked as resolved.

@SuaYoo

This comment was marked as resolved.

@emma-sg emma-sg requested a review from SuaYoo June 23, 2025 22:33
@emma-sg
Copy link
Member Author

emma-sg commented Jun 23, 2025

I think a simpler fix might be to move fetchWorkflows to the firstUpdated callback

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.

@emma-sg emma-sg merged commit 53a3521 into main Jun 23, 2025
27 checks passed
@emma-sg emma-sg deleted the frontend-fix-pagination-bug branch June 23, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Workflow list doesn't load page specified in URL on first load
2 participants