Possible Bug with Duplicated Dates on Drag Selection
Opened this issue · 0 comments
nktnet1 commented
Hi,
I believe there's an issue with the dates being duplicated in the date array passed into "onChange".
This can be reproduced by:
- Select a cell (e.g. Cell A).
- Click an unselected cell (e.g. Cell B) and simultaneously drag it onto the selected Cell A.
Array will contain ["Cell A", "Cell B", "Cell A"].
Problem reproducible in sandbox:
https://codesandbox.io/s/objective-pateu-y8lr0?file=/src/App.js
Currently using the following as a temporary workaround:
const [schedule, setSchedule] = React.useState([])
// ...
const handleChange = (newSchedule) => {
// setSchedule(schedule) // has duplicates - below will filter date to be unique.
setSchedule([...new Set(schedule.map(date => +date))].map(timestamp => new Date(timestamp)));
}
Thanks :) - Really appreciate your work!