Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixing bug that does not allow group.height property to function #858

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`getGroupWithItemDimensions should work as expected 1`] = `
exports[`getOrderedGroupsWithItems should work as expected 1`] = `
Object {
"1": Object {
"group": Object {
Expand Down
18 changes: 18 additions & 0 deletions __tests__/utils/calendar/get-group-with-item-dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,23 @@ describe('getGroupWithItemDimensions', ()=>{
props.stackItems
)).not.toBe(groupWithItems)
})
it('should allow for the group.height property to override the manual calculation', () => {
const testHeight = 567.6
const groupWithItemsAndSetHeight ={
group: {id: '1', height: testHeight},
items
}
const result = getGroupWithItemDimensions(
groupWithItemsAndSetHeight,
props.keys,
state.canvasTimeStart,
state.canvasTimeEnd,
state.width*3,
props.lineHeight,
props.itemHeightRatio,
props.stackItems
)
expect(result.height).toEqual(testHeight)
})
})

2 changes: 1 addition & 1 deletion __tests__/utils/calendar/get-ordered-groups-with-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {items, groups} from '../../../__fixtures__/itemsAndGroups'
import {props} from '../../../__fixtures__/stateAndProps'


describe('getGroupWithItemDimensions', ()=>{
describe('getOrderedGroupsWithItems', ()=>{
it('should work as expected', ()=>{
expect(getOrderedGroupsWithItems(groups, items, props.keys)).toMatchSnapshot()
})
Expand Down
8 changes: 7 additions & 1 deletion src/lib/utility/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,13 @@ export function getGroupWithItemDimensions(
itemHeightRatio
})
})
const { groupHeight } = stackGroup(itemDimensions, stackItems, lineHeight)
//If group height property is specified, use that instead of manual calculation
let groupHeightProp = null;
if (groupWithItems && groupWithItems.group) groupHeightProp = groupWithItems.group.height
const { groupHeight } = groupHeightProp ?
{ groupHeight: groupHeightProp } :
stackGroup(itemDimensions, stackItems, lineHeight)

return {
...groupWithItems,
itemDimensions: itemDimensions,
Expand Down