Skip to content

Commit 9a0e551

Browse files
committed
container height always positive
1 parent cf6a73f commit 9a0e551

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/AutoSizer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ const AutoSizer = ({
155155
const paddingBottom = parseInt(style.paddingBottom) || 0;
156156

157157
// find new dimensions
158-
const newHeight = (parent.offsetHeight || 0) - paddingTop - paddingBottom;
159-
const newWidth = (parent.offsetWidth || 0) - paddingLeft - paddingRight;
158+
const newHeight = Math.max((parent.offsetHeight || 0) - paddingTop - paddingBottom, 0);
159+
const newWidth = Math.max((parent.offsetWidth || 0) - paddingLeft - paddingRight, 0);
160160

161161
// update state
162162
if (newHeight !== containerHeight || newWidth !== containerWidth) {

0 commit comments

Comments
 (0)