react-date-range
react-date-range copied to clipboard
Date view jumps to selected data, after any Calendar property changes value
Subject of the issue
Whenever a property, such as color, or showSelectionPreview changes its value on <Calendar ,
the view will jump to the selected/focused day view.
I found a workaround to disable it:
useEffect(() => {
if (calendarRef.current !== null) {
calendarRef.current.updateShownDate = () => {};
}
});
Why I change a property value after initialization, see here: https://github.com/hypeserver/react-date-range/issues/527
[BUG] Bug Reproduce Steps
const [triggerReloadHack, setTriggerReloadHack] = useState(true);
useEffect(() => {
setTimeout(() => {
setTriggerReloadHack(prev => !prev);
}, 3000);
}, []);
return
<Calendar color={triggerReloadHack ? '#3d91ff' : '#3d91ff'} preventSnapRefocus: true, />
[BUG] Expected behaviour
- it will not jump to focused date when any prop changes on Calendar
Environment
Package Version: 1.4.0, also occurs on 1.1.4 React version: 17.0.2 Node version: 14.13.0 Browser: Chrome
related issues
Those issues seem not to be the same, but similar. They prevent range jumping of view. This one is about Calendar and caused by another action.
- https://github.com/hypeserver/react-date-range/issues/441
- https://github.com/hypeserver/react-date-range/pull/516
+1