Skip to content

scheduler does not conform to the outside parent div #107

Open
@AsifDaum

Description

@AsifDaum

Checklist

  • I've verified that I'm running react-big-schedule version 4.2.0 or higher

Describe the bug

The scheduler does not conform to the outside parent div no matter what I try, the second issue is that when I change the viewType, from day to week or month, the entire scheduler expands outside the div and will not look functional.

Currently the scheduler does not conform to the outside div:

266804314-cd7c7c2e-f373-4c9f-9bd0-44875642e45e

If I change to week:

image

If I rerender the component it reshapes itself back to a normal size, but its still not conforming to the outside div.

image

I have tried the

  1. responsiveByParent route Specific usage of responsiveByParent hbatalhaStch/react-big-scheduler#26
  2. Scheduler does not respect the size of the parent container. (version 4.2.1) #52
    Which is running react not in strict mode, my production version has the same identical issues.
  3. besidesWidth: window.innerWidth <= 1600 ? 100 : 350, // you need to add this

None have worked so far, from my understanding it seems that the resource table have a dynamic width that increases its size dependent on the width rather than the events table.

What could it be and what should I be trying? I would really like this to work in my application.

Reproduction Link/Code


  const schedulerParentRef = useRef();
  var today = new Date();
  var date = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate();
  let schedulerData = new SchedulerData(
    date,
    ViewType.Day, // Change the status of daily, weekly or monthly
    false,
    false,
    {
      eventItemPopoverPlacement: "bottomRightMousePosition",
      responsiveByParent: true,
      besidesWidth: window.innerWidth <= 1600 ? 100 : 350,
      startResizable: false,
      endResizable: false,
      schedulerContentHeight: "100%",
      weekCellWidth: 80,
      dayCellWidth: 40,
    }
  );
  schedulerData.setResources([]);
  schedulerData.setEvents([]);

  useEffect(() => {
    dispatch(initialiseViewModel(schedulerData));

    return () => dispatch(reInitialiseViewModel());
  }, [date, dispatch, initialiseViewModel, reInitialiseViewModel]);

  const changeDate = (e) => {
    setDateState(e);
  };

  const getResources = useCallback(() => {
    getAuthorization()
      .get(`company/get_companyschedule_recources?assigned_to=${DropDownValue}`)
      .then((res) => {
        setResources(res.data.message ? [] : res.data);
        dispatch(setAPIDetailsUser(res.data.message ? [] : res.data));
        getEvents(); // Get events after resources have been set
      })
      .catch((err) => {
        console.log("Error in getting schedule", err);
      });
  }, [dispatch, DropDownValue]);

  const getEvents = useCallback(() => {
    getAuthorization()
      .get(`company/get_companyschedule_events?assigned_to=${DropDownValue}`)
      .then((res) => {
        setEvents(res.data.message ? [] : res.data);
        dispatch(setAPIDetailsUserEvents(res.data.message ? [] : res.data));
        setDataLoaded(true); // Set dataLoaded to true after both resources and events are set
      })
      .catch((err) => {
        console.log("Error in getting schedule", err);
      });
  }, [dispatch, DropDownValue]);

  //Set Scheduler Data
  useEffect(() => {
    if (dataLoaded) {
      viewModel.setResources(Resources);
      viewModel.setEvents(Events);
      dispatch(setViewModel(viewModel));
      setDataLoaded(false); // Reset after processing the loaded data
    }
  }, [dataLoaded, Resources, Events, DropDownValue]);

  useEffect(() => {
    setDataLoaded(false); // Reset the dataLoaded state before fetching
    getResources();
  }, [DropDownValue, getResources]);

  const prevClick = (schedulerData) => {
    schedulerData.prev();
    schedulerData.setEvents(Events);
    dispatch(setViewModel(schedulerData));
  };

  const nextClick = (schedulerData) => {
    schedulerData.next();
    schedulerData.setEvents(Events);
    dispatch(setViewModel(schedulerData));
  };

  const onViewChange = (schedulerData, view) => {
    schedulerData.setViewType(view.viewType, view.showAgenda, view.isEventPerspective);
    schedulerData.setEvents(Events);
    dispatch(setViewModel(schedulerData));
  };

  const onSelectDate = (schedulerData, date) => {
    schedulerData.setDate(date);
    schedulerData.setEvents(Events);
    dispatch(setViewModel(schedulerData));
  };

  const eventClicked = (schedulerData, event) => {
    setOpen(true);
    getAuthorization()
      .get(`company/schedule_view/${event.id}/`)
      .then((res) => {
        setScheduleDetails(res.data);
        setDateState([new Date(`${res.data.start_date}`), new Date(`${res.data.end_date}`)]);
      })
      .catch((err) => {
        console.log("Error in getting schedule details", err);
      });
  };

  const ops1 = (schedulerData, event) => {
    setOpen(true);
    getAuthorization()
      .get(`company/schedule_detail/${event.id}/`)
      .then((res) => {
        setScheduleDetails(res.data);
      })
      .catch((err) => {
        console.log("Error in getting schedule details", err);
      });
    // alert(
    //   `You just executed ops1 to event: {id: ${event.id}, title: ${
    //     event.title
    //   }}`
    // );
  };
  
    return (
    <div className="w-full" ref={schedulerParentRef}>
      {displayTimeline && (
        <div className="-mt-4" style={{ marginLeft: "auto" }}>
          <Scheduler
            parentRef={schedulerParentRef}
            schedulerData={viewModel}
            prevClick={prevClick}
            nextClick={nextClick}
            onSelectDate={onSelectDate}
            onViewChange={onViewChange}
            eventItemClick={eventClicked}
            viewEventClick={ops1}
            viewEventText="Details"
          />
        </div>
      )}

Steps to reproduce

  1. view scheduler and notice that its not the right size
  2. click on week and it jumps outside of the div

Operating System

windows

Browser

firefox

React version

^18.0.2

react-big-schedule version

^4.2.5

Additional Information

No response

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