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

feat(react-virtualized-extension docs): add filterable demo, fix for filtering+scrolling #4389

Merged
merged 4 commits into from
Jun 19, 2020
Merged
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
Expand Up @@ -36,7 +36,7 @@ export const DEFAULT_SCROLLING_RESET_TIME_INTERVAL = 150;
let size = 0;

function scrollbarSize(recalc: boolean) {
if ((!size && size !== 0 || recalc) && canUseDOM) {
if (((!size && size !== 0) || recalc) && canUseDOM) {
const scrollDiv = document.createElement('div');
scrollDiv.style.position = 'absolute';
scrollDiv.style.top = '-9999px';
Expand All @@ -51,7 +51,6 @@ function scrollbarSize(recalc: boolean) {
return size;
}


/**
* Controls whether the VirtualGrid updates the DOM element's scrollLeft/scrollTop based on the current state or just observes it.
* This prevents VirtualGrid from interrupting mouse-wheel animations (see issue #2).
Expand Down Expand Up @@ -249,8 +248,6 @@ interface InstanceProps {
prevIsScrolling: boolean;
prevScrollToColumn: number;
prevScrollToRow: number;
prevScrollLeft?: number;
prevScrollTop?: number;

columnSizeAndPositionManager: ScalingCellSizeAndPositionManager;
rowSizeAndPositionManager: ScalingCellSizeAndPositionManager;
Expand Down Expand Up @@ -364,17 +361,15 @@ export class VirtualGrid extends React.Component<VirtualGridProps, VirtualGridSt
prevIsScrolling: props.isScrolling === true,
prevScrollToColumn: props.scrollToColumn,
prevScrollToRow: props.scrollToRow,
prevScrollLeft: props.scrollLeft,
prevScrollTop: props.scrollTop,

scrollbarSize: 0,
scrollbarSizeMeasured: false
},
isScrolling: false,
scrollDirectionHorizontal: SCROLL_DIRECTION_FORWARD,
scrollDirectionVertical: SCROLL_DIRECTION_FORWARD,
scrollLeft: props.scrollLeft || 0,
scrollTop: props.scrollTop || 0,
scrollLeft: 0,
scrollTop: 0,
scrollPositionChangeReason: null,

needToResetStyleCache: false
Expand Down Expand Up @@ -794,7 +789,6 @@ export class VirtualGrid extends React.Component<VirtualGridProps, VirtualGridSt
*/
static getDerivedStateFromProps(nextProps: VirtualGridProps, prevState: VirtualGridState): VirtualGridState {
const newState: VirtualGridState = {};
const { instanceProps } = prevState;

if (
(nextProps.columnCount === 0 && prevState.scrollLeft !== 0) ||
Expand All @@ -806,8 +800,8 @@ export class VirtualGrid extends React.Component<VirtualGridProps, VirtualGridSt
// only use scroll{Left,Top} from props if scrollTo{Column,Row} isn't specified
// scrollTo{Column,Row} should override scroll{Left,Top}
} else if (
(nextProps.scrollLeft !== instanceProps.prevScrollLeft && nextProps.scrollToColumn < 0) ||
(nextProps.scrollTop !== instanceProps.prevScrollTop && nextProps.scrollToRow < 0)
(nextProps.scrollLeft !== prevState.scrollLeft && nextProps.scrollToColumn < 0) ||
(nextProps.scrollTop !== prevState.scrollTop && nextProps.scrollToRow < 0)
) {
Object.assign(
newState,
Expand All @@ -819,6 +813,8 @@ export class VirtualGrid extends React.Component<VirtualGridProps, VirtualGridSt
);
}

let { instanceProps } = prevState;

// Initially we should not clearStyleCache
newState.needToResetStyleCache = false;
if (
Expand Down Expand Up @@ -890,8 +886,6 @@ export class VirtualGrid extends React.Component<VirtualGridProps, VirtualGridSt
instanceProps.prevRowHeight = nextProps.rowHeight;
instanceProps.prevScrollToColumn = nextProps.scrollToColumn;
instanceProps.prevScrollToRow = nextProps.scrollToRow;
instanceProps.prevScrollLeft = nextProps.scrollLeft;
instanceProps.prevScrollTop = nextProps.scrollTop;

// getting scrollBarSize (moved from componentWillMount)
instanceProps.scrollbarSize = nextProps.getScrollbarSize();
Expand Down Expand Up @@ -1386,7 +1380,10 @@ export class VirtualGrid extends React.Component<VirtualGridProps, VirtualGridSt
return VirtualGrid._getCalculatedScrollLeft(props, state);
}

static _getScrollLeftForScrollToColumnStateUpdate(nextProps: VirtualGridProps, prevState: VirtualGridState): VirtualGridState {
static _getScrollLeftForScrollToColumnStateUpdate(
nextProps: VirtualGridProps,
prevState: VirtualGridState
): VirtualGridState {
const { scrollLeft } = prevState;
const calculatedScrollLeft = VirtualGrid._getCalculatedScrollLeft(nextProps, prevState);

Expand Down Expand Up @@ -1460,7 +1457,10 @@ export class VirtualGrid extends React.Component<VirtualGridProps, VirtualGridSt
}
}

static _getScrollTopForScrollToRowStateUpdate(nextProps: VirtualGridProps, prevState: VirtualGridState): VirtualGridState {
static _getScrollTopForScrollToRowStateUpdate(
nextProps: VirtualGridProps,
prevState: VirtualGridState
): VirtualGridState {
const { scrollTop } = prevState;
const calculatedScrollTop = VirtualGrid._getCalculatedScrollTop(nextProps, prevState);

Expand Down
Loading