-
-
Notifications
You must be signed in to change notification settings - Fork 47.8k
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
RangePicker: choose which months are displayed on calendars #15360
Comments
There is |
wonder if it's just me but I couldn't get |
@arash-kiani-cko below is how I use <template>
<a-range-picker :defaultPickerValue="dateRange" />
</template>
<script>
import moment from 'moment'
export default {
data () {
return {
dateRange: [moment().add(-1, 'month'), moment()],
}
},
}
</script> |
it doesn't work can anybody help me, please? |
step 1: step 2: step 3: To sum up based on the range of dates selected i need to show those months when i open the calendar thanks in advance. |
Hi guys, I am facing issue with Range Picker. I wanted to show previous month and current month in rangePicker, I'm able to do that with defaultPickerValue. But the issue is when i select start date from picker. Range picker gets reset to current month and next month. can anyone please help. Thanks in advance! Eg: |
Facing the same issue myself. Using defaultPickerValue, shows the desired months on initial load. But when I open and change anything it resorts to showing the current month and the one after. |
I'm facing the same issue. Once I choose the start date, it automatically "focuses" to the end date ignoring any values set in defaultPickerValue.
Now I have click previous month 12 times again to select 2020-01-01 as the end date too It seems like we need a pickerValue rather than just defaultPickerValue |
Is there any workaround for this? |
Same issue here. I have some tests using it, and some days work, another days it fails because of that issue. |
to prevent month to jump use same date in start/end , ex. |
I would also like this feature. As others have pointed out, using defaultPickerValue only works for the initial rendering, but we need a way to update it based on selected dates. |
Faced this issue, found a quick and easy hack to sidestep it temporarily: const [key, setKey] = useState("1");
useEffect(
()=>{
setKey(key === "1" ? "2" : "1")
},
[someDate.getTime(), someOtherDate.getTime()]
)
)
<RangePicker
key={key}
defaultPickerValue={[someDate, someOtherDate]}
...
/> Now every time any of the defaultPickerValues change the react key is changed, remounting the component from scratch. Meaning defaultPickerValue will be used every time it remounts, acting somewhat like a controlled component. Not optimal perfornance-wise for sure, but gets the job done. |
Picker component has been refactor in Please feel free to create new issue if you have any further question :) Picker 组件于 如果有任何问题,欢迎随时创建新的 issue :) |
What problem does this feature solve?
We develop an application that is used for financial bookkeeping and use
RangePicker
s to filter past operations. Our use case focuses on dates in the past, and since filtering for the future makes no sense, we disable these dates usingdisabledDate
property ofRangePicker
. A simplified example of the disabling logic:By default, when
RangePicker
has value set to a single day or the date range fits on the same month, the value is displayed on the left calendar and right calendar displays the following month – this setting is controlled byshowDate
variable in component's state. But since we disable future dates, the following month is always disabled in our pickers:It would make much more sense in out case to be able to decide which month is displayed by default on which side, so that the user by default sees this:
We believe the use case is universal enough to make into the library – it can be used to guide the user to pick the date range in the very specific month and be complemented by a advanced date disabling logic. Other solutions like predefined date ranges do not solve it for us and we do not want to maintain internal fork of a entire library for a simple change like this.
What does the proposed API look like?
We tried different approaches and the simplest and most obvious seems to be the most effective: allow replacing the logic of the getShowDateFromValue function with function from component props.
Suggested changes:
replace every occurrence of
getShowDateFromValue(value) || showDate
and derivatives inside the class component (like here and here) with method call:So I propose to add a property
to
DatePicker.RangePicker
component.If you approve of the suggestion, I can send a pull request with implementation.
The text was updated successfully, but these errors were encountered: