This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
feat(IM-5878): consider scroll position when taking snapshot #520
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import { useMemo } from "@nebula.js/stardust"; | ||
import createViewService from "../services/view-service"; | ||
import type { PivotLayout } from "../types/QIX"; | ||
import type { PageInfo, ViewService } from "../types/types"; | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
const useViewService = (pageInfo: PageInfo): ViewService => useMemo(() => createViewService(), [pageInfo.page]); | ||
const useViewService = (layout: PivotLayout, pageInfo: PageInfo): ViewService => | ||
useMemo( | ||
() => createViewService(layout.snapshotData), | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[layout.snapshotData, pageInfo.page], | ||
); | ||
|
||
export default useViewService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import type { stardust } from "@nebula.js/stardust"; | ||
import React, { useCallback } from "react"; | ||
import React, { useCallback, useEffect } from "react"; | ||
import type { Model } from "../../types/QIX"; | ||
import { | ||
ScrollableContainerOrigin, | ||
|
@@ -50,6 +50,10 @@ export const StickyPivotTable = ({ | |
const { visibleLeftDimensionInfo, visibleTopDimensionInfo } = useVisibleDimensions(layoutService, qPivotDataPages); | ||
const { changeSortOrder, changeActivelySortedHeader } = useSorting(model, layoutService.layout.qHyperCube); | ||
|
||
const isPrintingMode = !!layoutService.layout.snapshotData; | ||
// const scrollLeft = isPrintingMode ? viewService.scrollLeft ?? 0 : 0; | ||
const scrollTopPartially = isPrintingMode ? viewService.rowPartialHeight ?? 0 : 0; | ||
|
||
const { headersData, measureData, topDimensionData, leftDimensionData, attrExprInfoIndexes, nextPageHandler } = | ||
useData(qPivotDataPages, layoutService, pageInfo, visibleLeftDimensionInfo, visibleTopDimensionInfo); | ||
|
||
|
@@ -123,6 +127,14 @@ export const StickyPivotTable = ({ | |
const headerCellRowHightCallback = useCallback(() => headerCellHeight, [headerCellHeight]); | ||
const contentCellRowHightCallback = useCallback(() => contentCellHeight, [contentCellHeight]); | ||
|
||
useEffect(() => { | ||
const element = verticalScrollableContainerRef.current; | ||
if (element) { | ||
// element.scrollLeft = scrollLeft; | ||
element.scrollTop = scrollTopPartially; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I definitely need to add a similar property for scrolLeft and other conditions if there are more, but maybe we can focus on vertical scroll for this PR |
||
} | ||
}, [scrollTopPartially, verticalScrollableContainerRef]); | ||
|
||
return ( | ||
<ScrollableContainer | ||
ref={verticalScrollableContainerRef} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { ViewService } from "../../../../types/types"; | ||
|
||
export const getViewState = (viewService: ViewService) => ({ | ||
rowPartialHeight: 125, | ||
visibleTopIndex: 5, | ||
visibleRows: 16, | ||
page: 0, | ||
rowsPerPage: 0, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import type { SnapshotData } from "../types/QIX"; | ||
import type { ViewService } from "../types/types"; | ||
|
||
const createViewService = (): ViewService => ({ | ||
const createViewService = (snapshotData: SnapshotData | undefined): ViewService => ({ | ||
gridColumnStartIndex: 0, | ||
gridRowStartIndex: 0, | ||
gridWidth: 0, | ||
gridHeight: 0, | ||
rowPartialHeight: snapshotData?.content?.rowPartialHeight ?? 0, | ||
visibleTopIndex: snapshotData?.content?.visibleTopIndex, | ||
visibleRows: snapshotData?.content?.visibleRows, | ||
rowsPerPage: snapshotData?.content?.rowsPerPage, | ||
page: snapshotData?.content?.page, | ||
}); | ||
|
||
export default createViewService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure pageInfo.page should be in the dependencies. It was there before, so I kept it as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageInfo.page
in deps means that the view service is "reset" or re-created when page changes. Which is what we want since all states in viewService are based on the current page.