Skip to content

Commit

Permalink
fix(inventoryList): issues/403 adjust for expanded guestsList (#460)
Browse files Browse the repository at this point in the history
* graphCard, remove default minHeight prop
* inventoryList, autoUpdate prop
* minHeight, flip autoUpdate, inner container height for reset
  • Loading branch information
cdcabrera committed Oct 13, 2020
1 parent 51e4b41 commit 22cf693
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ exports[`GraphCard Component should render a non-connected component: non-connec
>
<MinHeight
autoUpdate={false}
key="headerMinHeight"
minHeight={0}
>
<CardHeader>
Expand Down Expand Up @@ -123,6 +124,7 @@ exports[`GraphCard Component should render a non-connected component: non-connec
</MinHeight>
<MinHeight
autoUpdate={false}
key="bodyMinHeight"
minHeight={0}
>
<CardBody>
Expand Down Expand Up @@ -198,6 +200,7 @@ exports[`GraphCard Component should render multiple states: error with 403 statu
>
<MinHeight
autoUpdate={false}
key="headerMinHeight"
minHeight={0}
>
<CardHeader>
Expand Down Expand Up @@ -250,6 +253,7 @@ exports[`GraphCard Component should render multiple states: error with 403 statu
</MinHeight>
<MinHeight
autoUpdate={false}
key="bodyMinHeight"
minHeight={0}
>
<CardBody>
Expand Down Expand Up @@ -321,6 +325,7 @@ exports[`GraphCard Component should render multiple states: error with 500 statu
>
<MinHeight
autoUpdate={false}
key="headerMinHeight"
minHeight={0}
>
<CardHeader>
Expand Down Expand Up @@ -373,6 +378,7 @@ exports[`GraphCard Component should render multiple states: error with 500 statu
</MinHeight>
<MinHeight
autoUpdate={false}
key="bodyMinHeight"
minHeight={0}
>
<CardBody>
Expand Down Expand Up @@ -444,6 +450,7 @@ exports[`GraphCard Component should render multiple states: fulfilled 1`] = `
>
<MinHeight
autoUpdate={false}
key="headerMinHeight"
minHeight={0}
>
<CardHeader>
Expand Down Expand Up @@ -496,6 +503,7 @@ exports[`GraphCard Component should render multiple states: fulfilled 1`] = `
</MinHeight>
<MinHeight
autoUpdate={false}
key="bodyMinHeight"
minHeight={0}
>
<CardBody>
Expand Down Expand Up @@ -567,6 +575,7 @@ exports[`GraphCard Component should render multiple states: pending 1`] = `
>
<MinHeight
autoUpdate={false}
key="headerMinHeight"
minHeight={0}
>
<CardHeader>
Expand Down Expand Up @@ -619,6 +628,7 @@ exports[`GraphCard Component should render multiple states: pending 1`] = `
</MinHeight>
<MinHeight
autoUpdate={false}
key="bodyMinHeight"
minHeight={0}
>
<CardBody>
Expand Down
4 changes: 2 additions & 2 deletions src/components/graphCard/graphCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class GraphCard extends React.Component {

return (
<Card className="curiosity-usage-graph">
<MinHeight autoUpdate={false}>
<MinHeight key="headerMinHeight">
<CardHeader>
<CardTitle>
<Title headingLevel="h2" size="lg">
Expand All @@ -200,7 +200,7 @@ class GraphCard extends React.Component {
</CardActions>
</CardHeader>
</MinHeight>
<MinHeight autoUpdate={false}>
<MinHeight key="bodyMinHeight">
<CardBody>
<div className={(error && 'blur') || 'fadein'}>
{pending && <Loader variant="graph" />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ exports[`InventoryList Component should handle variations in data: filtered data
</CardHeader>
</MinHeight>
<MinHeight
autoUpdate={true}
autoUpdate={false}
key="bodyMinHeight-10"
minHeight={0}
>
Expand Down Expand Up @@ -249,7 +249,7 @@ exports[`InventoryList Component should handle variations in data: variable data
</CardHeader>
</MinHeight>
<MinHeight
autoUpdate={true}
autoUpdate={false}
key="bodyMinHeight-10"
minHeight={0}
>
Expand Down Expand Up @@ -349,7 +349,7 @@ exports[`InventoryList Component should render a non-connected component: non-co
</CardHeader>
</MinHeight>
<MinHeight
autoUpdate={true}
autoUpdate={false}
key="bodyMinHeight-10"
minHeight={0}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/inventoryList/inventoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class InventoryList extends React.Component {

return (
<Card className="curiosity-inventory-card">
<MinHeight key="headerMinHeight">
<MinHeight key="headerMinHeight" autoUpdate>
<CardHeader>
<CardTitle>
<Title headingLevel="h2" size="lg">
Expand Down Expand Up @@ -202,7 +202,7 @@ class InventoryList extends React.Component {
</div>
</CardBody>
</MinHeight>
<MinHeight key="footerMinHeight">
<MinHeight key="footerMinHeight" autoUpdate>
<CardFooter className={(error && 'blur') || ''}>
<TableToolbar isFooter>
<Pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ exports[`MinHeight Component should render a non-connected component: non-connec
}
}
>
lorem ipsum
<div>
lorem ipsum
</div>
</div>
`;
4 changes: 3 additions & 1 deletion src/components/minHeight/__tests__/minHeight.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ describe('MinHeight Component', () => {
});

it('should set minHeight in relation to contents and props', () => {
const props = {};
const props = {
autoUpdate: true
};
const component = shallow(<MinHeight {...props}>lorem ipsum</MinHeight>);

expect(component.instance().setMinHeight).toBeDefined();
Expand Down
9 changes: 6 additions & 3 deletions src/components/minHeight/minHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { helpers } from '../../common';
class MinHeight extends React.Component {
containerRef = React.createRef();

innerContainerRef = React.createRef();

updatedMinHeight = 0;

updatedContainerWidth = 0;
Expand Down Expand Up @@ -58,9 +60,10 @@ class MinHeight extends React.Component {
const { updatedMinHeight } = this;
const { minHeight: overrideMinHeight } = this.props;
const { current: domElement = {} } = this.containerRef;
const { current: innerDomElement = {} } = this.innerContainerRef;

if (resetMinHeight && domElement.style) {
domElement.style.minHeight = 0;
domElement.style.minHeight = innerDomElement?.clientHeight || 0;
}

const clientHeight = domElement?.clientHeight || 0;
Expand Down Expand Up @@ -102,7 +105,7 @@ class MinHeight extends React.Component {

return (
<div ref={this.containerRef} style={{ minHeight: updatedMinHeight }}>
{children}
<div ref={this.innerContainerRef}>{children}</div>
</div>
);
}
Expand All @@ -125,7 +128,7 @@ MinHeight.propTypes = {
* @type {{minHeight: number, autoUpdate: boolean}}
*/
MinHeight.defaultProps = {
autoUpdate: true,
autoUpdate: false,
minHeight: 0
};

Expand Down

0 comments on commit 22cf693

Please sign in to comment.