From 5f371ea9fa2aa5bdc7bde906481c8cf9ee2ea89b Mon Sep 17 00:00:00 2001 From: emma Date: Wed, 18 Jun 2025 12:58:02 -0400 Subject: [PATCH 1/6] only reset page if switching filters; otherwise, load initial page from URL --- frontend/src/pages/org/workflows-list.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/org/workflows-list.ts b/frontend/src/pages/org/workflows-list.ts index 89c259132c..4c3ba16c3f 100644 --- a/frontend/src/pages/org/workflows-list.ts +++ b/frontend/src/pages/org/workflows-list.ts @@ -148,7 +148,11 @@ export class WorkflowsList extends BtrixElement { changedProperties.has("filterBy") ) { void this.fetchWorkflows({ - page: 1, + page: + // If we've already loaded workflows and are switching filters, reset the page; otherwise, use the page from the URL or default to 1 + this.workflows + ? 1 + : parsePage(new URLSearchParams(location.search).get("page")) || 1, }); } if (changedProperties.has("filterByCurrentUser")) { From efa3b7a6e6bd89450d50adaf5417fe70dcf3a6f9 Mon Sep 17 00:00:00 2001 From: emma Date: Wed, 18 Jun 2025 12:58:27 -0400 Subject: [PATCH 2/6] always render `` so that page updates always occur in url --- frontend/src/pages/org/workflows-list.ts | 43 ++++++++++++------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/frontend/src/pages/org/workflows-list.ts b/frontend/src/pages/org/workflows-list.ts index 4c3ba16c3f..00f7adb866 100644 --- a/frontend/src/pages/org/workflows-list.ts +++ b/frontend/src/pages/org/workflows-list.ts @@ -4,6 +4,7 @@ import type { SlDialog, SlSelectEvent, } from "@shoelace-style/shoelace"; +import clsx from "clsx"; import { html, type PropertyValues } from "lit"; import { customElement, query, state } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -513,27 +514,27 @@ export class WorkflowsList extends BtrixElement { ${this.workflows.items.map(this.renderWorkflowItem)} - ${when( - total > pageSize, - () => html` -
- { - await this.fetchWorkflows({ - page: e.detail.page, - }); - - // Scroll to top of list - // TODO once deep-linking is implemented, scroll to top of pushstate - this.scrollIntoView({ behavior: "smooth" }); - }} - > -
- `, - )} +
+ { + await this.fetchWorkflows({ + page: e.detail.page, + }); + + // Scroll to top of list + // TODO once deep-linking is implemented, scroll to top of pushstate + this.scrollIntoView({ behavior: "smooth" }); + }} + > +
`; } From 26846e86dc3bf75848ae664933c5f0032323db36 Mon Sep 17 00:00:00 2001 From: emma Date: Mon, 23 Jun 2025 15:10:09 -0400 Subject: [PATCH 3/6] update intial render logic to not depend on loaded data --- frontend/src/pages/org/workflows-list.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/org/workflows-list.ts b/frontend/src/pages/org/workflows-list.ts index 00f7adb866..b801ebc546 100644 --- a/frontend/src/pages/org/workflows-list.ts +++ b/frontend/src/pages/org/workflows-list.ts @@ -148,12 +148,20 @@ export class WorkflowsList extends BtrixElement { changedProperties.has("filterByScheduled") || changedProperties.has("filterBy") ) { + const isInitialRender = [ + "orderBy", + "filterByCurrentUser", + "filterByScheduled", + "filterBy", + ] + .map((k) => changedProperties.get(k)) + .every((v) => v === undefined); void this.fetchWorkflows({ page: - // If we've already loaded workflows and are switching filters, reset the page; otherwise, use the page from the URL or default to 1 - this.workflows - ? 1 - : parsePage(new URLSearchParams(location.search).get("page")) || 1, + // If this is the initial render, use the page from the URL or default to 1; otherwise, reset the page to 1 + isInitialRender + ? parsePage(new URLSearchParams(location.search).get("page")) || 1 + : 1, }); } if (changedProperties.has("filterByCurrentUser")) { From abc0a36ff111ca4f172dbcf3d3b61346851ddcd7 Mon Sep 17 00:00:00 2001 From: emma Date: Mon, 23 Jun 2025 18:31:03 -0400 Subject: [PATCH 4/6] fix page sets not changing internal page state --- frontend/src/components/ui/pagination.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/ui/pagination.ts b/frontend/src/components/ui/pagination.ts index 9742bbdacc..e2a23ea691 100644 --- a/frontend/src/components/ui/pagination.ts +++ b/frontend/src/components/ui/pagination.ts @@ -173,6 +173,7 @@ export class Pagination extends LitElement { set page(page: number) { if (page !== this._page) { this.setPage(page); + this._page = page; } } From 58696e5a43481454530a3c7d929631dd780e3d8e Mon Sep 17 00:00:00 2001 From: emma Date: Mon, 23 Jun 2025 18:32:25 -0400 Subject: [PATCH 5/6] simplify/clean up data fetching & page reset prop checks --- frontend/src/pages/org/workflows-list.ts | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/frontend/src/pages/org/workflows-list.ts b/frontend/src/pages/org/workflows-list.ts index b801ebc546..cabf512a69 100644 --- a/frontend/src/pages/org/workflows-list.ts +++ b/frontend/src/pages/org/workflows-list.ts @@ -142,18 +142,20 @@ export class WorkflowsList extends BtrixElement { protected async willUpdate( changedProperties: PropertyValues & Map, ) { - if ( - changedProperties.has("orderBy") || - changedProperties.has("filterByCurrentUser") || - changedProperties.has("filterByScheduled") || - changedProperties.has("filterBy") - ) { - const isInitialRender = [ - "orderBy", - "filterByCurrentUser", - "filterByScheduled", - "filterBy", - ] + // Props that reset the page to 1 when changed + const resetToFirstPageProps = [ + "filterByCurrentUser", + "filterByScheduled", + "filterBy", + "orderBy", + ]; + + // Props that require a data refetch + const refetchDataProps = [...resetToFirstPageProps]; + + if (refetchDataProps.some((k) => changedProperties.has(k))) { + console.log(changedProperties); + const isInitialRender = resetToFirstPageProps .map((k) => changedProperties.get(k)) .every((v) => v === undefined); void this.fetchWorkflows({ From 1d2629e7679ff9077dc11c23b43111685dd8cadb Mon Sep 17 00:00:00 2001 From: emma Date: Mon, 23 Jun 2025 18:32:40 -0400 Subject: [PATCH 6/6] remove console log --- frontend/src/pages/org/workflows-list.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/pages/org/workflows-list.ts b/frontend/src/pages/org/workflows-list.ts index cabf512a69..34fa9b45cb 100644 --- a/frontend/src/pages/org/workflows-list.ts +++ b/frontend/src/pages/org/workflows-list.ts @@ -154,7 +154,6 @@ export class WorkflowsList extends BtrixElement { const refetchDataProps = [...resetToFirstPageProps]; if (refetchDataProps.some((k) => changedProperties.has(k))) { - console.log(changedProperties); const isInitialRender = resetToFirstPageProps .map((k) => changedProperties.get(k)) .every((v) => v === undefined);