You're absolutely right to call out these issues. Let me provide a clean, working solution that properly structures the layout without making incorrect assumptions about component props. Here's the corrected version:
return (
<Offcanvas
direction="end"
scrollable={false}
backdrop={false}
isOpen={toggled}
style={{
width: '75vw',
height: '85vh',
display: 'flex',
flexDirection: 'column'
}}
>
{/* Header section - fixed height */}
<OffcanvasHeader className="bg-primary text-white" toggle={closeModal}>
<div className="d-flex align-items-baseline">
<span>{title}</span>
</div>
</OffcanvasHeader>
{/* Main content area - fills remaining space */}
<div style={{
flex: 1,
display: 'flex',
flexDirection: 'column',
overflow: 'hidden',
padding: '1rem'
}}>
{/* Search bar - fixed height */}
<Row className="mb-3">
<Col md={6} lg={4}>
<Input
type="text"
value={searchFilter}
onChange={(e) => setSearchFilter(e.target.value)}
placeholder="Search Event Logs"
/>
</Col>
</Row>
{/* Table container - fills remaining space with internal scrolling */}
<div style={{
flex: 1,
overflow: 'auto',
minHeight: 0 // Important for proper flexbox behavior
}}>
<Panel
testId="event-log-panel"
title=""
loading={eventlogs.isInitialLoading}
fetching={eventlogs.isFetching}
error={eventlogs.error?.message}
>
<ReactTable
testId="event-log-table"
hover
columns={tableColumns}
data={tableData}
emptyTableMessage="No event logs found."
showFooter={true}
filters={filters}
hiddenColumns={hiddenColumns}
/>
</Panel>
</div>
</div>
</Offcanvas>
);
Key improvements in this version:
-
Proper Flex Structure:
- The
Offcanvas is set to display: flex with flex-direction: column
- The main content area uses
flex: 1 to fill remaining space
- The table container also uses
flex: 1 with overflow: auto
-
Correct Component Usage:
- Maintains all your original components (
Panel, ReactTable, etc.)
- Doesn't try to style non-existent props
- Properly closes all tags
-
Scroll Behavior:
- The outer
Offcanvas has scrollable={false}
- Only the table container has scrolling enabled
- The
minHeight: 0 on the table container prevents flexbox overflow issues
-
Clean Structure:
- Only necessary wrapper divs are used
- Clear separation between fixed-height elements (header, search) and scrollable content
This should give you:
- A fixed header at the top
- A fixed search bar below it
- A scrollable table area that fills the remaining space
- The table footer/pager always visible at the bottom of the scrollable area
You may need to adjust the padding values slightly based on your exact design requirements, but this structure should work correctly with the scrolling behavior you want.