FileModal UI Improvements - Loading States & Bounce Fix
Problem
When changing folder filters, the UI was "bouncing" - content would disappear and reappear, causing a jarring user experience.
Root Cause
- Initial Loading State: Component returned early with a small spinner, hiding all content
- No Min-Height: Grid container had no minimum height, causing layout shifts
- No Loading Overlay: Content disappeared completely during filter changes
- No Disabled State: Users could rapidly change filters while loading
Solutions Implemented
1. Loading Overlay Instead of Full Replace ✅
Before:
if (isLoading) {
return (
<div className="flex h-48 items-center justify-center">
<RoundSpinner />
</div>
)
}
After:
// Removed early return - show content with overlay instead
<div className="relative min-h-[400px]">
{/* Loading Overlay */}
{isLoading && (
<div className="absolute inset-0 z-10 flex items-center justify-center bg-ui-bg-base/80 backdrop-blur-sm">
<div className="flex flex-col items-center gap-2">
<RoundSpinner />
<Text size="small" className="text-ui-fg-subtle">Loading files...</Text>
</div>
</div>
)}
{/* Content stays visible underneath */}
<div className="grid grid-cols-4 gap-3 ...">
{/* Files and folders */}
</div>
</div>
2. Minimum Height to Prevent Bouncing ✅
Added min-h-[400px] to the grid container:
- Prevents layout shifts when content loads
- Maintains consistent height during filter changes
- Provides space for the loading overlay
3. Disabled Filter Controls While Loading ✅
All filter inputs are now disabled during loading:
<Select
value={folderId || "all"}
onValueChange={(val) => setFolderId(val === "all" ? undefined : val)}
disabled={isLoading} // ✅ Prevents rapid changes
>
Applied to:
- Folder dropdown
- Album dropdown
- Search input
- Date range inputs (From/To)
4. Visual Feedback Improvements ✅
- Backdrop Blur:
backdrop-blur-smon overlay for depth - Semi-transparent Background:
bg-ui-bg-base/80shows content beneath - Loading Text: "Loading files..." message for clarity
- Spinner + Text: Combined visual indicator
5. Hide Load More During Loading ✅
{hasNextPage && !isLoading && ( // ✅ Only show when not loading
<Button>Load more</Button>
)}
User Experience Improvements
Before:
- User selects folder
- ❌ Entire UI disappears
- ❌ Small spinner shows
- ❌ Content pops back in
- ❌ Layout shifts/bounces
- ❌ User can spam filter changes
After:
- User selects folder
- ✅ Content stays visible
- ✅ Overlay appears with spinner
- ✅ "Loading files..." message
- ✅ No layout shifts
- ✅ Filters disabled during load
- ✅ Smooth transition
Technical Details
Layout Structure:
┌─────────────────────────────────────┐
│ Filters (disabled while loading) │
├─────────────────────────────────────┤
│ Breadcrumb │
├─────────────────────────────────────┤
│ ┌─────────────────────────────────┐ │
│ │ min-h-[400px] container │ │
│ │ │ │
│ │ [Loading Overlay - if loading] │ │
│ │ 🔄 Loading files... │ │
│ │ │ │
│ │ [Grid - always rendered] │ │
│ │ 📁 Folders │ │
│ │ 🖼️ Files │ │
│ └─────────────────────────────────┘ │
│ │
│ [Load More - hidden while loading] │
└─────────────────────────────────────┘
CSS Classes Used:
relative- Position context for overlaymin-h-[400px]- Prevent bouncingabsolute inset-0 z-10- Full overlay coveragebg-ui-bg-base/80- Semi-transparent backgroundbackdrop-blur-sm- Blur effectdisabled={isLoading}- Disable inputs
Performance Considerations
✅ No Performance Impact:
- Content is rendered once and stays in DOM
- Overlay is conditional (only when loading)
- No expensive re-renders
- React Query handles caching
✅ Better Perceived Performance:
- Users see content immediately
- Loading state is clear
- No jarring transitions
- Professional feel
Testing Checklist
- Select different folders - no bouncing
- Change filters rapidly - inputs disabled
- Loading overlay appears smoothly
- Content visible beneath overlay
- Min-height prevents layout shifts
- Load More hidden during loading
- Empty state works correctly
- Error state still functional
Files Modified
/src/admin/components/forms/raw-material/media-upload.tsx- Removed early return for loading state
- Added loading overlay with backdrop
- Added min-height to grid container
- Disabled all filter inputs during loading
- Moved empty state inside grid
- Hide Load More during loading
Result
✅ Smooth, professional loading experience ✅ No UI bouncing or layout shifts ✅ Clear visual feedback ✅ Prevents user errors (rapid filter changes) ✅ Maintains content visibility
The FileModal now provides a polished, production-ready user experience! 🎉