Skip to content

Conversation

@DominikB2014
Copy link
Contributor

@DominikB2014 DominikB2014 commented Jan 13, 2026

This brings us closer to supporting useQuery in dashboards. I tried to do everything with as minimum changes as possible to avoid any regressions.

@linear
Copy link

linear bot commented Jan 13, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 13, 2026
@DominikB2014 DominikB2014 marked this pull request as ready for review January 13, 2026 20:05
@DominikB2014 DominikB2014 requested a review from a team as a code owner January 13, 2026 20:05
@DominikB2014 DominikB2014 marked this pull request as draft January 13, 2026 20:35
- Fix stale `selection` prop in `transformTable` call by reading from `latestPropsRef`
- Fix stale `dashboardFilters` in `applyDashboardFilters` by reading from `latestPropsRef`
- Remove setting `queryFetchIDRef` to undefined which caused race condition with active fetches
- Refactor queue to use `fetchDataRef` instead of passing function directly
- Change deduplication to be based on `fetchDataRef` identity instead of `widgetId`
  - This solves the remount issue where a new component instance would be blocked by an old queued request
  - Each component instance now has its own `fetchDataRef`, enabling proper per-instance deduplication
- Add `skipDashboardFilterParens` to `latestPropsRef` to avoid stale closure
- Remove unnecessary eslint-disable directive

These changes address the stale closure bugs identified in PR review comments where widgets would fetch or display data using outdated props when filters changed while requests were queued.
Reset `queryFetchIDRef.current` to undefined when adding a fetch to the queue.
This prevents a race condition where an active (not queued) fetch could complete
with stale data after props change, briefly displaying incorrect results before
the newly queued fetch with updated props executes.

Matches the behavior of the original class component implementation.
Copy link
Member

@narsaynorath narsaynorath left a comment

Choose a reason for hiding this comment

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

🫡 Nice

@DominikB2014 DominikB2014 merged commit c92bce9 into master Jan 14, 2026
53 checks passed
@DominikB2014 DominikB2014 deleted the dominikbuszowiecki/browse-238-convert-generic-widget-queries-to-a-functional-component branch January 14, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants