fix: update loading state handling in CalendarPage and DutyList components
- Set isLoading to false in CalendarPage to prevent unnecessary loading indicators. - Removed the loading spinner from CalendarHeader and adjusted rendering logic in DutyList to show a placeholder when data is not yet loaded for the month. - Enhanced tests in DutyList to verify behavior when data is empty and when data is loading, ensuring accurate user feedback during data fetching.
This commit is contained in:
@@ -30,13 +30,6 @@ export interface CalendarHeaderProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const HeaderSpinner = () => (
|
||||
<span
|
||||
className="block size-4 shrink-0 rounded-full border-2 border-transparent border-t-accent motion-reduce:animate-none animate-spin"
|
||||
aria-hidden
|
||||
/>
|
||||
);
|
||||
|
||||
function isCurrentMonth(month: Date): boolean {
|
||||
const now = new Date();
|
||||
return (
|
||||
@@ -82,16 +75,6 @@ export function CalendarHeader({
|
||||
aria-atomic="true"
|
||||
>
|
||||
{monthName(monthIndex)} {year}
|
||||
{isLoading && (
|
||||
<span
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
aria-label={t("loading")}
|
||||
className="flex items-center"
|
||||
>
|
||||
<HeaderSpinner />
|
||||
</span>
|
||||
)}
|
||||
</h1>
|
||||
{showToday && (
|
||||
<button
|
||||
@@ -116,10 +99,7 @@ export function CalendarHeader({
|
||||
disabled={disabled || isLoading}
|
||||
onClick={onRefresh}
|
||||
>
|
||||
<RefreshCwIcon
|
||||
className={cn("size-5", isLoading && "motion-reduce:animate-none animate-spin")}
|
||||
aria-hidden
|
||||
/>
|
||||
<RefreshCwIcon className="size-5" aria-hidden />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user