Skip to content

Scroll to start Date in initial load is not working for previous dates #201

Open
@Shreyas-sonu

Description

@Shreyas-sonu

Before Submitting

  • I have searched existing issues for similar bugs

Bug Description

Description
The React Big Schedule component is not displaying the specified custom date range (Jan 1, 2025 - Dec 31, 2025) upon initialization. Despite explicitly setting the start date to "2025-01-01" and configuring a custom view with specific date parameters, the scheduler still defaults to showing the current date range (requiring manual scrolling to reach January 2025).

Expected Behavior
The scheduler should initially render showing January 1, 2025, without requiring manual scrolling.
Actual Behavior
The scheduler initially renders showing the current date (today's date), requiring manual scrolling to navigate back to January 2025.

Reproduction

javascript// Initialize scheduler with custom date range
schedulerData = new SchedulerData(
"2025-01-01", // Set initial date to Jan 1, 2025
ViewType.Custom,
false,
false,
{
// Configuration settings
views: [{ viewName: 'Custom Time', viewType: ViewType.Custom, showAgenda: false, isEventPerspective: false }]
},
{
getCustomDateFunc: () => ({
startDate: "2025-01-01", // Explicitly define start date
endDate: "2025-12-31", // Explicitly define end date
cellUnit: CellUnit.Day
})
}
)

// Additional attempt to set date
schedulerData.setDate("2025-01-01");

// Set resources and events
schedulerData.setResources(resources);
schedulerData.setEvents(events);

Steps to Reproduce

1)Create a scheduler with ViewType.Custom
2)Set initial date to "2025-01-01" in constructor
3)Configure getCustomDateFunc to return specific date range "2025-01-01" to "2025-12-31"
4)Call schedulerData.setDate("2025-01-01") after initialization
5)nitialize the scheduler with resources and events
6)Observe that the scheduler still shows the current date instead of Jan 2025

Browser

Chrome

Operating System

Windows 11

React Version

18.2.0

react-big-schedule Version

4.4.5

Additional Context

I've verified that:

The custom date function is being called
The setDate method is working properly for navigation
Date parameters being passed are in the correct format
All dependencies (like dayjs) are correctly configured

I've tried multiple approaches:

Setting the date only in constructor
Setting the date only in getCustomDateFunc
Using both approaches simultaneously
Explicitly calling setDate after initialization
Using different view types (Year, Month, Custom)

None of these approaches successfully initialize the view to show January 2025 by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions