Skip to content

Commit

Permalink
second proposed fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick committed Oct 5, 2022
1 parent 269f8ca commit dc1931a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/time.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class Time extends React.Component {

static calcCenterPosition = (listHeight, centerLiRef) => {
return (
centerLiRef?.offsetTop - (listHeight / 2 - centerLiRef?.clientHeight / 2)
centerLiRef.offsetTop - (listHeight / 2 - centerLiRef.clientHeight / 2)
);
};

Expand Down Expand Up @@ -62,12 +62,14 @@ export default class Time extends React.Component {

componentDidMount() {
// code to ensure selected time will always be in focus within time window when it first appears
this.list.scrollTop = Time.calcCenterPosition(
this.props.monthRef
? this.props.monthRef.clientHeight - this.header.clientHeight
: this.list.clientHeight,
this.centerLi
);
this.list.scrollTop =
this.centerLi &&
Time.calcCenterPosition(
this.props.monthRef
? this.props.monthRef.clientHeight - this.header.clientHeight
: this.list.clientHeight,
this.centerLi
);
if (this.props.monthRef && this.header) {
this.setState({
height: this.props.monthRef.clientHeight - this.header.clientHeight,
Expand Down

0 comments on commit dc1931a

Please sign in to comment.