From 328fccbb8a3e5dddfc7ad5773aa2695b274142ed Mon Sep 17 00:00:00 2001 From: Dmytro-Melnyshyn <77053927+Dmytro-Melnyshyn@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:03:23 +0200 Subject: [PATCH] STSMACOM-880: `DateRangeFilter` - set the `wrongDatesOrder` to `false` when the field value changes. (#1546) (cherry picked from commit 93b1068cfa9fa660dc0175d3c386501f9a0ba950) --- CHANGELOG.md | 1 + .../components/DateRangeFilter/DateRangeFilter.js | 1 + .../DateRangeFilter/tests/DateRangeFilter-test.js | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fddbb88e7..025e4b7d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 9.2.6 * Use `` and `stripes.hasAnyPerm` to check for Notes assign/unassign perm. Fixes STSMACOM-875. +* `DateRangeFilter` - set the `wrongDatesOrder` to `false` when the field value changes. Fixes STSMACOM-880. ## [9.2.5](https://github.com/folio-org/stripes-smart-components/tree/v9.2.5) (2024-12-05) [Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v9.2.4...v9.2.5) diff --git a/lib/SearchAndSort/components/DateRangeFilter/DateRangeFilter.js b/lib/SearchAndSort/components/DateRangeFilter/DateRangeFilter.js index 2bdc97741..3954cb21c 100644 --- a/lib/SearchAndSort/components/DateRangeFilter/DateRangeFilter.js +++ b/lib/SearchAndSort/components/DateRangeFilter/DateRangeFilter.js @@ -169,6 +169,7 @@ const TheComponent = ({ ...filterValue, errors: { ...filterValue.errors, + wrongDatesOrder: false, // dates order is validated only when the "Apply" button is clicked, not when the field value is changed [errorName]: dateIsInvalid }, selectedValues: newSelectedValues diff --git a/lib/SearchAndSort/components/DateRangeFilter/tests/DateRangeFilter-test.js b/lib/SearchAndSort/components/DateRangeFilter/tests/DateRangeFilter-test.js index 7f44518db..f90c18cae 100644 --- a/lib/SearchAndSort/components/DateRangeFilter/tests/DateRangeFilter-test.js +++ b/lib/SearchAndSort/components/DateRangeFilter/tests/DateRangeFilter-test.js @@ -144,6 +144,15 @@ describe('DateRangeFilter', () => { it('should display corresponding error below the filter', () => ErrorInteractor('Start date is greater than end date').exists()); it('should not apply the filter', () => converge(() => { if (onChangeHandler.called) throw Error('expected onChangeHandler to not be called!'); })); + + describe('and then both dates were cleared', () => { + beforeEach(async () => { + await startPicker.fillIn(''); + await endPicker.fillIn(''); + }); + + it('should not display an error below the filter', () => ErrorInteractor('Start date is greater than end date').absent()); + }); }); describe('when date range is correct and "Apply" button was clicked', () => {