deseretdigital / dayzed

Primitives to build simple, flexible, WAI-ARIA compliant React date-picker components.
https://dayzed.netlify.app
MIT License
663 stars 27 forks source link

Changing offset with state #49

Closed anubra266 closed 2 years ago

anubra266 commented 2 years ago

How could I handle the moth offset when the selected state changes. E.g. If I change the selected state from an input to a date in June, I want to move the calendar from Janury to June.

Thanks

mkartchner994 commented 2 years ago

Here is an example of how you could do this around line 150 - https://codesandbox.io/s/dayzed-select-dropdown-example-5jrc4?file=/src/Single.js

You can use the date, offset, and onOffsetChanged props to control what dates are currently being displayed. The example uses select elements but you could also accomplish this by parsing a string from a text input and then updating the date and offset props accordingly if a valid date string is provided.

Hopefully that is helpful. Let me know if that doesn't answer the question. Thanks!

anubra266 commented 2 years ago

It does...thanks @mkartchner994