Skip to content

Commit

Permalink
fix: Fix bottomSheet height if the content is pretty small
Browse files Browse the repository at this point in the history
If the innerContent is smaller than the mediumHeight, we don't
want the BottomSheet to take all the available space. We want
to take only the needed place.
  • Loading branch information
Crash-- committed Nov 29, 2022
1 parent e8b3091 commit 884f89d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions react/BottomSheet/helpers.js
Expand Up @@ -26,7 +26,6 @@ export const computeMediumHeight = ({
}) => {
const mediumHeightOrWithRatio =
mediumHeight || Math.round(maxHeight * mediumHeightRatio)

if (backdrop) {
if (mediumHeightOrWithRatio < innerContentHeight) {
return mediumHeightOrWithRatio < maxHeight
Expand All @@ -35,7 +34,7 @@ export const computeMediumHeight = ({
}
return innerContentHeight > maxHeight ? maxHeight : innerContentHeight
}

if (innerContentHeight < mediumHeightOrWithRatio) return innerContentHeight
return mediumHeightOrWithRatio > maxHeight
? maxHeight
: mediumHeightOrWithRatio
Expand Down
11 changes: 11 additions & 0 deletions react/BottomSheet/helpers.spec.js
Expand Up @@ -57,6 +57,17 @@ describe('computeMediumHeight', () => {

expect(res).toBe(800)
})

it('should return the innerContentHeight if innerContentHeight < mediumHeight', () => {
const res = computeMediumHeight({
backdrop: false,
maxHeight: 800,
mediumHeight: 400,
innerContentHeight: 200
})

expect(res).toBe(200)
})
})

describe('with backdrop', () => {
Expand Down

0 comments on commit 884f89d

Please sign in to comment.