question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onSelect callback when using withRange() should pass an EventType

See original GitHub issue

Currently, 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.

  1. Add two additional callbacks onSelectionStart() and onSelectionEnd()
  2. 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:closed
  • Created 7 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
offskycommented, Feb 27, 2017

Ok, this was actually pretty easy. PR coming tomorrow.

1reaction
offskycommented, Mar 6, 2017

That looks good to me. You’re just missing the onSelect prop.

<InfiniteCalendar 
  width={400} 
  height={300} 
  Component={withRange(Calendar)} 
  selected={{ start: new Date(), end: new Date() }}
  onSelect={function(data) {
     console.log(data.start, data.end, data.eventType)
  }}
/>
Read more comments on GitHub >

github_iconTop 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 >
Jmol Files - SourceForge
An interactive viewer for three-dimensional chemical structures.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found