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

STSMACOM-880: DateRangeFilter - set the wrongDatesOrder to false when the field value changes. #1546

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Use `<IfAnyPermission>` and `stripes.hasAnyPerm` to check for Notes assign/unassign perm. Fixes STSMACOM-875.
* Fetch updaters in `<ViewMetaData>` on `props.metadata` changes. Fixes STSMACOM-878.
* Use `this.resources` in `StripesConnectedSource` instead of accessing props directly. Fixes STSMACOM-879.
* `DateRangeFilter` - set the `wrongDatesOrder` to `false` when the field value changes. Fixes STSMACOM-880.

## [9.2.0](https://github.com/folio-org/stripes-smart-components/tree/v9.2.0) (2024-10-11)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v9.1.3...v9.2.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If previously this error was shown on change and now it doesn't - then this change could affect a lot of other modules and their tests, maybe some QA test cases.
Can we follow the approach from <DateFilter> in stripes-inventory-components where we listen to reset events and clear inputs by ref?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BogdanDenis
The approach in stripes-inventory-components just resets the value, but the state of errors is reset in the handleDateChange function. The problem is that the error message related to wrongDatesOrder doesn't disappear, and this is due to the recent change in the handleDateChange function. It seems that it was changed by accident, because this bug is still fixed. The wrongDatesOrder was always applied when the "Apply" button was hit, and there was no requirement to change this behavior.

[errorName]: dateIsInvalid
},
selectedValues: newSelectedValues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading