onSelect callback when using withRange() should pass an EventType
See original GitHub issueCurrently, when you are selecting a range of dates using the withRange() HOC, the onSelect callback gets called every time the range changes. When the user clicks the second time to fix the range, the onSelect callback gets called again. There is not currently a way to differentiate between the start click, the end click and all the middle mouse movements. This is important information that the parent app will need to have. At the minimum, the app needs to know when the user has stopped selecting a range of dates so that it can do whatever expensive processing it needs to do.
I see two ways to do this.
- Add two additional callbacks
onSelectionStart()
andonSelectionEnd()
- Add some metadata to the object passed to
onSelect()
to distinguish what type of event it is
{
start: DATE,
end: DATE,
selectStart: false,
isSelecting: true,
selectEnd: false
}
This way, the app can ignore the noise, if it only cares about the final range.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
onchange event on input type=range is not triggering in ...
Just note that with this solution, in chrome you will get two calls to the handler (one per event), so if you care...
Read more >onchange vs. oninput for Range Sliders - Impressive Webs
I think the expected behaviour in such a case is that the value should display instantly, as the user is moving the slider,...
Read more >Infinite scrolling date-picker built with React, with localization ...
onSelect callback when using withRange() should pass an EventType. Currently, when you are selecting a range of dates using the withRange() HOC, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, this was actually pretty easy. PR coming tomorrow.
That looks good to me. You’re just missing the onSelect prop.