Skip to content

fix: security issue and bug when remount CalendarStrip #385

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

Open
wants to merge 2 commits into
base: master
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"moment": ">=2.0.0",
"node-git-hooks": "^1.0.1",
"prop-types": "^15.6.0",
"recyclerlistview": "^3.0.0"
"recyclerlistview": ">3.0.0"
},
"peerDependencies": {
"react": "*",
Expand Down
8 changes: 4 additions & 4 deletions src/Scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class CalendarScroller extends Component {
return;
}
const newIndex = Math.max(this.state.visibleStartIndex - this.state.numVisibleItems, 0);
this.rlv.scrollToIndex(newIndex, true);
this.rlv?.scrollToIndex(newIndex, true);
}

// Scroll right, guarding against end index.
Expand All @@ -123,7 +123,7 @@ export default class CalendarScroller extends Component {
this.rlv.scrollToEnd(true); // scroll to the very end, including padding
return;
}
this.rlv.scrollToIndex(newIndex, true);
this.rlv?.scrollToIndex(newIndex, true);
}

// Scroll to given date, and check against min and max date if available.
Expand Down Expand Up @@ -192,12 +192,12 @@ export default class CalendarScroller extends Component {
for (let i = 0; i < data.length; i++) {
if (data[i].date.isSame(prevVisStart, "day")) {
this.shifting = true;
this.rlv.scrollToIndex(i, false);
this.rlv?.scrollToIndex(i, false);
// RecyclerListView sometimes returns position to old index after
// moving to the new one. Set position again after delay.
this.timeoutResetPositionId = setTimeout(() => {
this.timeoutResetPositionId = null;
this.rlv.scrollToIndex(i, false);
this.rlv?.scrollToIndex(i, false);
this.shifting = false; // debounce
}, 800);
break;
Expand Down