Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
During testing found a bug where occasionally the date range will hav…
…e an end date in 1970/1969 even though the calendar is displaying selection for 2023. Attempting to locate the cause for this issue to correct it
  • Loading branch information
jsweet-dev committed May 25, 2023
commit db2b450a1552310d2b10c05b6e2a4a52c198aa8d
3 changes: 3 additions & 0 deletions src/components/Calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class Calendar extends PureComponent {
);
};
onDragSelectionStart = date => {
console.log(`onDragSelectionStart: ${date}`);
const { onChange, dragSelectionEnabled } = this.props;

if (dragSelectionEnabled) {
Expand All @@ -351,6 +352,7 @@ class Calendar extends PureComponent {
};

onDragSelectionEnd = date => {
console.log(`onDragSelectionEnd: ${date}`);
const { updateRange, displayMode, onChange, dragSelectionEnabled } = this.props;

if (!dragSelectionEnabled) return;
Expand All @@ -372,6 +374,7 @@ class Calendar extends PureComponent {
}
};
onDragSelectionMove = date => {
console.log(`onDragSelectionMove: ${date}`);
const { drag } = this.state;
if (!drag.status || !this.props.dragSelectionEnabled) return;
this.setState({
Expand Down
2 changes: 2 additions & 0 deletions src/components/DateRange/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class DateRange extends Component {
this.styles = generateStyles([coreStyles, props.classNames]);
}
calcNewSelection = (value, isSingleValue = true) => {
console.log(`calcNewSelection: ${JSON.stringify(value)}`);
console.log(`isSingleValue: ${isSingleValue}`);
const focusedRange = this.props.focusedRange || this.state.focusedRange;
const {
ranges,
Expand Down
35 changes: 22 additions & 13 deletions src/components/DayCell/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DayCell extends Component {
this.state = {
hover: false,
active: false,
touchOverDay: null,
touchOverDay: props.day.toISOString(),
};
}

Expand All @@ -24,35 +24,43 @@ class DayCell extends Component {
};

handleTouchEvent = event => {
console.log('handleTouchEvent: ', event.type);
const { day, disabled, onMouseDown, onMouseUp, onMouseEnter, onPreviewChange } = this.props;
const stateChanges = {};
if (disabled) {
onPreviewChange();
return;
}

const isNewDay = targetElements => {
if (targetElements && targetElements[2].className === 'rdrDay') {
const newDay = targetElements[2].getAttribute('data-day');
if (newDay !== this.state.touchOverDay) {
return newDay;
}
}
return null;
};

switch (event.type) {
case 'touchmove':
{
const targetElement = document.elementsFromPoint(
const targetElements = document.elementsFromPoint(
event.touches[0].clientX,
event.touches[0].clientY
);
if (targetElement && targetElement[2].className === 'rdrDay') {
const newDay = targetElement[2].getAttribute('data-day');
if (newDay !== this.state.touchOverDay) {
onMouseEnter(new Date(newDay));
onPreviewChange(new Date(newDay));
this.setState({ touchOverDay: newDay });
}
const newDay = isNewDay(targetElements);
if (newDay) {
console.log('New day: ', newDay);
onMouseEnter(new Date(newDay));
onPreviewChange(new Date(newDay));
this.setState({ touchOverDay: newDay });
}
}
break;
case 'touchend':
{
onMouseUp(new Date(this.state.touchOverDay));
this.setState({ touchOverDay: null });
}
onMouseUp(new Date(this.state.touchOverDay));
this.setState({ touchOverDay: null });
break;
case 'touchstart':
stateChanges.active = true;
Expand All @@ -62,6 +70,7 @@ class DayCell extends Component {
};

handleMouseEvent = event => {
console.log('handleMouseEvent: ', event.type);
const { day, disabled, onPreviewChange, onMouseEnter, onMouseDown, onMouseUp } = this.props;
const stateChanges = {};
if (disabled) {
Expand Down