question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

week view headers misaligned with day columns

See original GitHub issue

Do you want to request a feature or report a bug?

Bug report

What’s the current behavior?

on:

 "react-big-calendar": "^0.20.2"
  "react": "^16.5.2",
 "react-ace": "^5.8.0",

Week view (and day view on narrow screens) has completely misaligned headers with the day columns image

What’s the expected behavior?

The headers are aligned like in this sandbox

I looked at the markup differences between the sandbox and my code and here is an image showing it: image with the main differences highlighted.

Aside from the rbc-overflowing class being added the to the top level header component there are a number of markup differences in the structure as well.

The code for init is:

<Paper style={{marginTop: 10, height: '85vh'}}>
    <BigCalendar
        drilldownView="agenda"
        // onEventDrop={this.moveEvent}
        events={events || api[showing].data()}
        onSelectEvent={ (event) => api[showing].navigator(push)(event)}
        defaultView='month'
        scrollToTime={moment().toDate()}
        eventPropGetter={(event,start,end,isSelected)=>{
            return {
                style: {
                    backgroundColor:'transparent',
                    color: Colors.primary,
                    borderRadius:0,
                    border: 'none',
                    whiteSpace: 'pre-wrap',
                    overflowY: 'auto'
                }
            }
        }} 
        components={{
            event: this.Event,
            agenda: {
                event: this.EventAgenda
            },
            toolbar: CustomToolbar,
        }}
    />
</Paper>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
TomasHubelbauercommented, Mar 4, 2019

I managed to run into this by creating a RBC demo in CRA. The reproduction is as follows:

  • Create a new CRA app
  • Remove all CRA’s styles
  • Replace App.tsx with the following code:
import React from 'react';
import 'react-big-calendar/lib/css/react-big-calendar.css';
import BigCalendar from 'react-big-calendar';
import moment from 'moment';

type AppProps = {};

type AppState = {};

type CalendarEvent = {
  start: Date;
  end: Date;
  title: string;
}

export default class App extends React.Component<AppProps, AppState> {
  private static readonly localizer = BigCalendar.momentLocalizer(moment);
  
  render() {
    const start = new Date()
    start.setHours(10);
    const end = new Date();
    end.setHours(22);
    return (
      <BigCalendar<CalendarEvent>
        localizer={App.localizer}
        events={[ { start, end, title: 'An event' } ]}
        defaultView="week"
      />
    );
  }
}

Upon loading the page, the day column headers will be completely off screen. Switching the view to month and back fixes that. This might be a different issue that manifests the same way.

Please reopen this @buddythumbs as in my case this issue doesn’t seem to be fixable by removing the surrounding container (I do need to keep at least one div as React won’t allow me to render to body directly) and it reproduces consistently.

0reactions
Virthusscommented, Mar 4, 2021

I’m still having the issue. As for @TomasHubelbauer I can’t remove the surrounding block and because of this I can’t update my header. Any fix?

EDIT: For anone having this issue and using Material-UI with React. You can configure your calendar container to be astyled component and override the react-big-calendar there:

const Root = styled(Box)({
  '@global': {
    '.rbc-header, .rbc-time-header-gutter': {
      minWidth: '121px !important',  // THIS LINE PREVENTS HEADER CELLS TO BE SMALLER THAN THEIR EVENTS
      border: 'none !important',
      boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.15) !important'
    },
    '.rbc-day-bg': { minWidth: '120px !important' }
  }
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

week view headers misaligned with day columns · Issue #1129
Week view (and day view on narrow screens) has completely misaligned headers with the day columns image. What's the expected behavior?
Read more >
Why are these HTML column headers misaligned?
a sticky header, with dynamic column widths (no declared table ... I got the borders to align by removing the display:block properties.
Read more >
Solved: How to work with columns that are not aligned
Solved: Hi community I have a large set of data with columns not aligned. Please could I know how to align these ....
Read more >
Grid Header Alignment Problem While Fixed Header - Telerik
I had static headers set to true and all visible columns had pixel widths. But I was getting the column values not aligned...
Read more >
trying to fix column misalignment between row headers and ...
You can see the issue by scrolling to the right. When Bootstrap is being used and I scroll all the way to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found