When using ngx-bootstrap bsDaterangepicker quick select ranges, the bsValueChange event emits only the selected Date[] value and does not expose which preset button was clicked.
If the application tries to detect the selected preset by comparing returned dates against configured ranges, multiple presets that generate the same range cannot be distinguished.
In such cases, the first matching preset is always selected.
Example Scenario
Configured presets:
ranges = [
{
id: 4,
label: 'Last 3 Months (Till Today)',
value: [new Date('2026-01-21'), new Date('2026-04-21')]
},
{
id: 26,
label: 'Last 90 Days',
value: [new Date('2026-01-21'), new Date('2026-04-21')]
}
];
Selection handler:
onValueChange(selectedRange: Date[]) {
const matched = ranges.find(
r =>
r.value[0].getTime() === selectedRange[0].getTime() &&
r.value[1].getTime() === selectedRange[1].getTime()
);
console.log(matched);
}
Steps to Reproduce
- Configure two presets that resolve to the same date range on a given day.
- Open
bsDaterangepicker.
- Click Last 90 Days.
- Observe emitted
Date[].
- Reverse lookup returns first match.
Actual Result
{
id: 4,
label: 'Last 3 Months (Till Today)'
}
Expected Result
{
id: 26,
label: 'Last 90 Days'
}
Impact
- Incorrect preset label shown
- Wrong preset ID stored
- Saved filters can be inaccurate
- Confusing UX for overlapping ranges
Suggested Enhancement
Expose selected quick-range preset metadata in event output, for example:
{
presetId: 26,
label: 'Last 90 Days',
value: [startDate, endDate]
}
This would avoid unreliable reverse-matching based only on dates.
When using ngx-bootstrap
bsDaterangepickerquick select ranges, thebsValueChangeevent emits only the selectedDate[]value and does not expose which preset button was clicked.If the application tries to detect the selected preset by comparing returned dates against configured ranges, multiple presets that generate the same range cannot be distinguished.
In such cases, the first matching preset is always selected.
Example Scenario
Configured presets:
Selection handler:
Steps to Reproduce
bsDaterangepicker.Date[].Actual Result
Expected Result
Impact
Suggested Enhancement
Expose selected quick-range preset metadata in event output, for example:
This would avoid unreliable reverse-matching based only on dates.