Skip to content

Commit ff7fced

Browse files
fix(components): add position relative styles to Table container (#430)
1 parent e58ba0a commit ff7fced

File tree

2 files changed

+642
-598
lines changed

2 files changed

+642
-598
lines changed

src/components/Table/Table.js

+38-26
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
* limitations under the License.
1414
*/
1515

16-
import React, { Component } from 'react';
16+
/** @jsx jsx */
17+
18+
import { Component } from 'react';
1719
import PropTypes from 'prop-types';
1820
import styled from '@emotion/styled';
19-
import { css } from '@emotion/core';
21+
import { jsx, css } from '@emotion/core';
2022

2123
import TableHead from './components/TableHead';
2224
import TableBody from './components/TableBody';
@@ -91,7 +93,7 @@ const noShadowStyles = ({ noShadow }) =>
9193
`;
9294

9395
const ScrollContainer = styled.div(containerStyles);
94-
const Container = styled.div`
96+
const ShadowContainer = styled.div`
9597
${shadowSingle};
9698
${noShadowStyles};
9799
`;
@@ -158,31 +160,41 @@ class Table extends Component {
158160
} = this.props;
159161
const { sortDirection, sortHover, sortedRow } = this.state;
160162

163+
/**
164+
* The position: relative; container is necessary because ShadowContainer
165+
* is a position: absolute; element
166+
*/
161167
return (
162-
<Container noShadow={noShadow}>
163-
<ScrollContainer rowHeaders={rowHeaders}>
164-
<StyledTable
165-
rowHeaders={rowHeaders}
166-
borderCollapsed={borderCollapsed}
167-
>
168-
<TableHead
169-
sortDirection={sortDirection}
170-
sortedRow={sortedRow}
171-
onSortBy={this.onSortBy}
172-
onSortEnter={this.onSortEnter}
173-
onSortLeave={this.onSortLeave}
174-
headers={headers}
175-
rowHeaders={rowHeaders}
176-
/>
177-
<TableBody
178-
rows={this.getSortedRows()}
168+
<div
169+
css={css`
170+
position: relative;
171+
`}
172+
>
173+
<ShadowContainer noShadow={noShadow}>
174+
<ScrollContainer rowHeaders={rowHeaders}>
175+
<StyledTable
179176
rowHeaders={rowHeaders}
180-
sortHover={sortHover}
181-
onRowClick={onRowClick}
182-
/>
183-
</StyledTable>
184-
</ScrollContainer>
185-
</Container>
177+
borderCollapsed={borderCollapsed}
178+
>
179+
<TableHead
180+
sortDirection={sortDirection}
181+
sortedRow={sortedRow}
182+
onSortBy={this.onSortBy}
183+
onSortEnter={this.onSortEnter}
184+
onSortLeave={this.onSortLeave}
185+
headers={headers}
186+
rowHeaders={rowHeaders}
187+
/>
188+
<TableBody
189+
rows={this.getSortedRows()}
190+
rowHeaders={rowHeaders}
191+
sortHover={sortHover}
192+
onRowClick={onRowClick}
193+
/>
194+
</StyledTable>
195+
</ScrollContainer>
196+
</ShadowContainer>
197+
</div>
186198
);
187199
}
188200
}

0 commit comments

Comments
 (0)