I am creating a custom Filter that will show a classic Date Picker.
However the Rendering of the popover is wrong/not happening as expected.
It looks like that the "classic" calendar pop over is visible only inside the th filters.
To make sure it wasn't a single library to act funny I tried to reproduce the same issue with 3 different DatePicker React libraries:
Hacker0x01/react-datepicker
gpbl/react-day-picker
airbnb/react-dates
I set up a simple sandbox where you can see the issue.
code sandbox
The first and the second seems like doing nothing, but in reality the pop over is created, you can see it from the console inspector.
(for example div class="react-datepicker-popper is created and has its css)
While the third is created in a modal to showcase that the input is actually working, is just the "inline" version rendering that is acting up.
Thanks for any suggestion or direction you can point me to,
and apologise in advance if this is not an issue with the fantastic react-table.
react-table: 6.5.3
I suspect the issue is that the table "cell" is a div and the overflow is being clipped. Therefore, any component that is expecting unrestrained space to overlay another element is not going to work (unless the overlay can be untangled from the component and be made to "ride" on the body tag or similar). So, it is probably an issue but determining if it is react-table or the component is debatable.
I had a quick look at the codesandbox and can see the impact. Not sure how to address it with those tools specifically but I might give it a go with another date-picker component I have been using lately.
react-bootstrap-date-picker has the same issue (and it is what I described - the
Popover from react-bootstrap - but only because I am already using that in other places).
I would not consider it a "flaw" in react-table that can be "fixed". Rather an interaction between components that needs to be resolved outside the components themselves.
I've had a further thought about this. The DIV making the header cell has "overflow: hidden" (as I suspected). If you do the following on your column definition with the datapicker you may find that your popover now works (it does with react-bootstrap-data-picker without any other changes):
getTheadThProps: ()=>{
return {
style: {
overflow: "inherit"
}
}
},
UPDATE: the above needs to be getTheadFilterThProps and needs to be at the "table" level and not in the column definition. You should probably also consider checking to make sure the column requires the change and only return the style change if it does.
I am using DayPickerInput from react-day-picker and i had to use:
getTheadFilterThProps={() => {
return {
style: { position: "inherit", overflow: "inherit" }
}
}}
Without position: "inherit" the date picker closed when clicked outside the width of the input filed
The points to note here are:
Most helpful comment
UPDATE: the above needs to be
getTheadFilterThPropsand needs to be at the "table" level and not in the column definition. You should probably also consider checking to make sure the column requires the change and only return the style change if it does.