Skip to content

🐞 Admin Portal: Dashboard doesn't automatically update when tab is clicked#2534

Open
Findeton wants to merge 2 commits intomainfrom
fix/meta-11606/main
Open

🐞 Admin Portal: Dashboard doesn't automatically update when tab is clicked#2534
Findeton wants to merge 2 commits intomainfrom
fix/meta-11606/main

Conversation

@Findeton
Copy link
Copy Markdown
Contributor

@Findeton Findeton self-assigned this Mar 20, 2026
@Findeton Findeton added the bug Something isn't working label Mar 20, 2026
@Findeton Findeton marked this pull request as ready for review March 30, 2026 11:30
Copilot AI review requested due to automatic review settings March 30, 2026 11:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure the Admin Portal dashboard data refreshes when the user returns to (clicks) the Dashboard tab, addressing the parent issue linked in the description.

Changes:

  • Adds a tab action intended to trigger a dashboard refresh when the Dashboard tab is clicked.
  • Introduces a refreshRef plumbing path in the Election dashboard to trigger an Apollo refetch() via a hidden button.
  • Aligns Election tabs behavior with existing Election Event dashboard refresh patterns.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/admin-portal/src/resources/ElectionEvent/ElectionEventTabs.tsx Adds a Dashboard tab action intended to trigger refresh via refreshRef.
packages/admin-portal/src/resources/Election/ElectionTabs.tsx Adds refreshRef + Dashboard tab action and attempts to pass refreshRef down to the dashboard.
packages/admin-portal/src/components/dashboard/election/Dashboard.tsx Adds hidden refresh button wired to Apollo refetch() and accepts refreshRef prop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 146 to 152
if (showDashboard) {
result.push({
label: t("electionScreen.tabs.dashboard"),
component: DashboardTab,
props: {refreshRef},
action: () => refreshRef.current?.click(),
})
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The props: {refreshRef} entry in the tab definition is currently ignored by the shared Tabs component (it only renders <SelectedComponent {...propsFromTabs} />). As a result, DashboardTab never receives refreshRef, so the hidden refresh button ref is never attached and action: () => refreshRef.current?.click() will always be a no-op. Fix by either (a) passing refreshRef as a prop to <Tabs ...> (so it gets forwarded to the selected component), or (b) enhancing Tabs to merge elements[selectedTab].props into the selected component props.

Copilot uses AI. Check for mistakes.
Comment on lines 303 to +306
label: t("electionEventScreen.tabs.dashboard"),
component: DashboardTab,
props: {refreshRef, handleChildMount},
action: () => refreshRef.current?.click(),
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tab action relies on refreshRef.current?.click(), but refreshRef is only placed on the tab object (props: {refreshRef, handleChildMount}) and the shared Tabs component does not pass per-tab props to the selected component. That means the dashboard’s hidden refresh button never receives the ref and this action will do nothing. Fix by passing refreshRef/handleChildMount to <Tabs> (common props) or by updating Tabs to apply elements[selectedTab].props when rendering the selected tab.

Copilot uses AI. Check for mistakes.
Comment on lines +96 to +97
onClick={() => {
doRefetch()
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hidden refresh <button> should set type="button" to avoid inadvertently submitting a surrounding form, and the handler should guard against missing query variables (e.g., canQueryStats false) before calling doRefetch(). Also consider handling the returned promise (e.g., void doRefetch() / catch) to avoid unhandled rejections if the refetch errors.

Suggested change
onClick={() => {
doRefetch()
type="button"
onClick={() => {
if (!canQueryStats) {
return
}
void doRefetch()

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants