Skip to content

Commit d94c36e

Browse files
committed
docs(architecture): add explanation of data loading strategy for dropdowns
- Introduce pre-fetching strategy using ThrottledFetchingService - Address limitations of Flutter DropdownButtonFormField - Describe implementation details and user experience - Highlight tradeoffs for initial data load vs. seamless UI
1 parent a0643cb commit d94c36e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Data Loading Strategy
3+
description: An explanation of the pre-fetching strategy for dropdown data in the web dashboard.
4+
---
5+
import { Aside } from '@astrojs/starlight/components';
6+
7+
A key architectural decision in the web dashboard is the strategy for loading data into selection fields, such as the `Country` and `Language` dropdowns found in the content creation and editing forms.
8+
9+
### The Challenge: UI Component Limitations
10+
11+
The dashboard uses the standard Flutter `DropdownButtonFormField` to ensure a consistent and native user experience. However, a known limitation of this widget is its lack of support for scroll detection or on-demand pagination. This makes it impossible to dynamically load more items as a user scrolls through a long list.
12+
13+
### The Solution: Pre-Fetching with `ThrottledFetchingService`
14+
15+
To provide a seamless user experience and work around this limitation, we've implemented a **pre-fetching strategy**.
16+
17+
When a user navigates to a section that requires this data (like Content Management), the `ContentManagementBloc` dispatches an event to fetch the *entire* list of required items (e.g., all countries, all languages) in the background.
18+
19+
This process is handled by the `ThrottledFetchingService`, which is designed to be efficient and respectful to the API:
20+
- It fetches the first page of data to understand the total scope.
21+
- It then fetches the remaining pages sequentially, with a small, built-in delay between each request to avoid overwhelming the server.
22+
23+
### The User Experience
24+
25+
This background fetching is designed to be as unobtrusive as possible.
26+
- If a user opens a form before the data has finished loading, the relevant dropdown menu will be temporarily disabled.
27+
- A helper text message, "Loading full list...", will appear below the dropdown to inform the user that the data is on its way.
28+
- Once the fetch is complete, the dropdown automatically becomes active, populated with the full list of options.
29+
30+
This approach represents a deliberate engineering tradeoff: we accept the cost of a larger initial data load in exchange for a smoother, more consistent user interface without the complexity of implementing custom dropdown components.

0 commit comments

Comments
 (0)