Skip to content

Commit 2d6e99e

Browse files
a-gierczakjquense
authored andcommitted
fix: misplacement of current time indicator (#1239)
Hello, It looked like PR for this issue (#1054) was abandoned and the bug still exists so I've decided to continue jdaberkow's work. Also I've added check for `getNow` prop, because when you want to implement timezones you may have different `getNow` function depending on which timezone is selected. When user changes the timezone indicator should move to correct position for that timezone.
1 parent 2a870b0 commit 2d6e99e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/DayColumn.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ class DayColumn extends React.Component {
4444
}
4545

4646
componentDidUpdate(prevProps, prevState) {
47-
if (prevProps.isNow !== this.props.isNow) {
47+
const getNowChanged = !dates.eq(
48+
prevProps.getNow(),
49+
this.props.getNow(),
50+
'minutes'
51+
)
52+
53+
if (prevProps.isNow !== this.props.isNow || getNowChanged) {
4854
this.clearTimeIndicatorInterval()
4955

5056
if (this.props.isNow) {
51-
this.setTimeIndicatorPositionUpdateInterval(
57+
const tail =
58+
!getNowChanged &&
59+
dates.eq(prevProps.date, this.props.date, 'minutes') &&
5260
prevState.timeIndicatorPosition === this.state.timeIndicatorPosition
53-
)
61+
62+
this.setTimeIndicatorPositionUpdateInterval(tail)
5463
}
5564
}
5665
}

0 commit comments

Comments
 (0)