Skip to content
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 @@ -109,6 +109,7 @@ UIIN-3437.
* Inventory Item: Add number generator button "Generate call number" to additional item call numbers. Refs UIIN-3608.
* Make `circulation-settings` dependency optional. Refs UIIN-3621.
* User without affiliation in member tenant is not able to see an item record. Fixes UIIN-3614.
* Item reorder changes are lost if holdings accordion is collapsed before 'stop item movement' invoked. Fixes UIIN-3626.

## [13.0.13](https://github.com/folio-org/ui-inventory/tree/v13.0.13) (2026-03-11)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v13.0.12...v13.0.13)
Expand Down
21 changes: 16 additions & 5 deletions src/Instance/HoldingsList/Holding/HoldingAccordion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PropTypes from 'prop-types';
import { useRef } from 'react';
import {
FormattedMessage,
useIntl,
Expand Down Expand Up @@ -93,6 +94,7 @@ const HoldingAccordion = ({
dragHandleListeners,
ref,
}) => {
const hasBeenOpenedRef = useRef(false);
const searchParams = {
limit: 0,
offset: 0,
Expand Down Expand Up @@ -163,15 +165,24 @@ const HoldingAccordion = ({
displayWhenClosed={holdingButtonsGroup(false)}
closedByDefault
>
{open => (
open && (
{open => {
if (open) {
hasBeenOpenedRef.current = true;
}

if (!hasBeenOpenedRef.current) return null;

return (
<Row>
<Col sm={12}>
<Col
sm={12}
style={{ display: open ? 'block' : 'none' }}
>
{children}
</Col>
</Row>
)
)}
);
}}
</Accordion>
);
};
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useHoldingItemsQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ const useHoldingItemsQuery = (
...omit(options.searchParams, ['sortBy']),
};

const queryKey = [namespace, options.key, holdingsRecordId, searchParams.offset, sortBy];
const queryKey = [namespace, options.key, holdingsRecordId, searchParams];
const queryFn = () => ky.get('inventory/items-by-holdings-id', { searchParams }).json();
const queryOptions = omit(options, ['searchParams']);
const { data, refetch, isLoading, isFetching } = useQuery({
queryKey,
queryFn,
...omit(options, ['searchParams']),
staleTime: queryOptions.staleTime ?? Infinity,
refetchOnMount: queryOptions.refetchOnMount ?? false,
...queryOptions,
});

return {
Expand Down
25 changes: 25 additions & 0 deletions src/hooks/useHoldingItemsQuery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe('useHoldingItemsQuery', () => {
}));

beforeEach(() => {
queryClient.clear();
mockGet.mockClear();
useOkapiKy.mockClear().mockReturnValue({
get: mockGet,
extend: jest.fn().mockReturnValue({ get: mockGet }),
Expand Down Expand Up @@ -110,4 +112,27 @@ describe('useHoldingItemsQuery', () => {
);
});
});

it('does not refetch on remount when request params are unchanged', async () => {
const id = items[0].holdingsRecordId;
const searchParams = { limit: 5, offset: 0 };

const { unmount } = renderHook(
() => useHoldingItemsQuery(id, { searchParams }),
{ wrapper }
);

await act(() => !queryClient.isFetching());
expect(mockGet).toHaveBeenCalledTimes(1);

unmount();

renderHook(
() => useHoldingItemsQuery(id, { searchParams }),
{ wrapper }
);

await act(() => !queryClient.isFetching());
expect(mockGet).toHaveBeenCalledTimes(1);
});
});
Loading