Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility to get selected range label for defined range component #530

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

atefBB
Copy link
Contributor

@atefBB atefBB commented Nov 4, 2021

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description

Add the possibility to get selected range label for defined range component

Related Issue: Solve this prob #228

@anthonynsimon
Copy link

Hey just wanted to chime in since I also needed this functionality.

In case it's helpful for anyone, you can implement this using the isSelected function on the list of default static ranges (or your own list). For example:

const onChangeHandler = (range) => {
  const knownRange = defaultStaticRanges.find((x) => x.isSelected(range.selection));
  
  if (knownRange) {
    console.log(`Selected known range ${knownRange.label}`)
  } else {
    console.log(`Selected custom range ${range.selection}`)
  }
}

@atefBB
Copy link
Contributor Author

atefBB commented Nov 6, 2021

@anthonynsimon nice shoot! I'll try it ! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants