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

UISACQCOMP-198: *BREAKING* useFilters - remove search term trimming. #788

Closed
wants to merge 1 commit into from
Closed
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 @@ -12,6 +12,7 @@
* ECS - Support affiliations select for the inventory field (`<ConsortiumFieldInventory>`). Refs UISACQCOMP-190.
* Add Print routing list functionality. Refs UISACQCOMP-191.
* ECS - Support central ordering in the acq modules. Refs UISACQCOMP-194.
* *BREAKING* `useFilters` - remove search term trimming. Refs UISACQCOMP-198.

## [5.1.1](https://github.com/folio-org/stripes-acq-components/tree/v5.1.1) (2024-04-22)
[Full Changelog](https://github.com/folio-org/stripes-acq-components/compare/v5.1.0...v5.1.1)
Expand Down
2 changes: 1 addition & 1 deletion lib/AcqList/hooks/useFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const useFilters = (resetData, initialFilters = {}) => {
);

const changeSearch = useCallback(
e => setSearchQuery(e.target.value?.trim()),
e => setSearchQuery(e.target.value),
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, after this change we'll have issues with spaces, I don't think it's correct fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NikitaSedyx - would it be acceptable to pass a flag to useFilters to be able to customize the trimming?

[],
);

Expand Down
23 changes: 23 additions & 0 deletions lib/AcqList/hooks/useFilters.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { act } from 'react';
import { renderHook } from '@testing-library/react-hooks';

import useFilters from './useFilters';

describe('useFilters', () => {
beforeEach(() => {
jest.clearAllMocks();
});

describe('when changing a search term', () => {
it('should not be trimmed to avoid a cursor shift', async () => {
const searchTerm = ' test foo ';
const event = { target: { value: searchTerm } };

const { result } = renderHook(useFilters);

await act(() => result.current.changeSearch(event));

expect(result.current.searchQuery).toBe(searchTerm);
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/stripes-acq-components",
"version": "5.1.1",
"version": "6.0.0",
"description": "Component library for Stripes Acquisitions modules",
"publishConfig": {
"registry": "https://repository.folio.org/repository/npm-folio/"
Expand Down
Loading