React DatePicker calendar showing behind table head

纵然是瞬间 提交于 2021-01-26 09:47:34

问题


I was using react datePicker and fixed-data-table-2 for my project. When I open the calendar, it shows behind table head. Here is the code for CSS file:

.ui-datepicker {
   z-index: 9999 !important;
}
.table{
   z-index: -1000  !important;
}

Here is React Code for DatePicker:

 <div className='ui-datepicker'>
           <DatePicker
                 selected={this.state.startDate}
                 selectsStart
                 startDate={this.state.startDate}
                 endDate={this.state.endDate}
                 onChange={this.onFilterStart}
            />
</div>

Here is shortcut code for Table:

<div className='table'>
     <Table
            rowHeight={50}
            rowsCount={tableData.getSize()}
            width={1000}
            maxHeight={1800}
            height={700}
            groupHeaderHeight={30}
            headerHeight={50}
            onColumnResizeEndCallback={this.resizeEndCallback}
            isColumnResizing={false}
            >
            <ColumnGroup
                header={<Cell>Basic Info</Cell>}>
                <Column columnKey='menuTranslation'
                        header={ <SortHeaderCell
                                languageChosen={this.state.languageChosen}
                                onSortChange={this.sortChange}
                                sortDir={colSortDirs.foodName}>Food 
              Name</SortHeaderCell>}
                        isResizable={true}
                        width={columnWidths.foodName}
                        cell={<MyTextCell data={tableData}  
              field='menuTranslation' col="menuTranslation"  />}
                />
<div>

This is the image for the problem:

image


回答1:


Try setting the z-index on .react-datepicker-popper instead of on datepicker. That's the className that react-date-picker uses on the popup it creates.

.react-datepicker-popper {
    z-index: 9999 !important;
}



回答2:


It's because of Material-UI Paper component styles. Paper component has an overflow: hidden style, and by removing it works perfectly.

import Card from "@material-ui/core/Card";
...
<Card>
<DayPickerInput  id="servdate" name="servdate"  dateFormat="yyyy-mm-dd"/>
</Card>

In style set .MuiCard-root{ overflow: visible!important; }



来源:https://stackoverflow.com/questions/52412685/react-datepicker-calendar-showing-behind-table-head

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!