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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* Fix Sonar issues. Refs [UILD-792].
* Fix for hidden menu bar. Refs [UILD-805].
* Fix for tooltip position. Refs [UILD-806].
* Fix for blank preview in editor while searching for complex values. Refs [UILD-807].

[UILD-792]:https://folio-org.atlassian.net/browse/UILD-792
[UILD-805]:https://folio-org.atlassian.net/browse/UILD-805
[UILD-806]:https://folio-org.atlassian.net/browse/UILD-806
[UILD-807]:https://folio-org.atlassian.net/browse/UILD-807

## 2.0.1 (2026-04-23)
* Fix for the case when changes to profile settings are not applied immediately. Fixes [UILD-798].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const AuthoritiesModal: FC<AuthoritiesModalProps> = ({
flow="value"
mode="custom"
onSubmitCallback={handleCloseMarcPreview}
managePreview={false}
>
<Search.Controls>
{/* Segment tabs - clicking triggers onSegmentChange, auto-resolves new config */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const HubsModal: FC<HubsModalProps> = ({ isOpen, onClose, assignedValue,
flow="value"
mode="custom"
onSubmitCallback={hubPreviewProps.handleCloseHubPreview}
managePreview={false}
>
<Search.Controls>
<Search.Controls.InputsWrapper />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const SubjectModal: FC<SubjectModalProps> = ({
handleCloseMarcPreview();
hubPreviewProps.handleCloseHubPreview();
}}
managePreview={false}
>
<Search.Controls>
<Search.Controls.SegmentGroup>
Expand Down
57 changes: 57 additions & 0 deletions src/features/search/ui/hooks/useSearchControlsHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,25 @@ describe('useSearchControlsHandlers', () => {
expect(resetFullDisplayComponentType).toHaveBeenCalled();
expect(resetCurrentlyPreviewedEntityBfid).toHaveBeenCalled();
});

it('skips preview management while configured not to when changing segment', () => {
const { result } = renderHook(() =>
useSearchControlsHandlers({
coreConfig: mockConfig,
uiConfig: mockUIConfig,
flow: 'url',
managePreview: false,
}),
);

act(() => {
result.current.onSegmentChange('browse');
});

expect(resetPreviewContent).not.toHaveBeenCalled();
expect(resetFullDisplayComponentType).not.toHaveBeenCalled();
expect(resetCurrentlyPreviewedEntityBfid).not.toHaveBeenCalled();
});
});

describe('onSourceChange', () => {
Expand Down Expand Up @@ -441,6 +460,25 @@ describe('useSearchControlsHandlers', () => {
expect(resetCurrentlyPreviewedEntityBfid).toHaveBeenCalled();
});

it('skips preview management while configured not to on submit', () => {
const { result } = renderHook(() =>
useSearchControlsHandlers({
coreConfig: mockConfig,
uiConfig: mockUIConfig,
flow: 'url',
managePreview: false,
}),
);

act(() => {
result.current.onSubmit();
});

expect(resetPreviewContent).not.toHaveBeenCalled();
expect(resetFullDisplayComponentType).not.toHaveBeenCalled();
expect(resetCurrentlyPreviewedEntityBfid).not.toHaveBeenCalled();
});

it('calls onSubmitCallback on submit when provided', () => {
const mockOnSubmitCallback = jest.fn();
const { result } = renderHook(() =>
Expand Down Expand Up @@ -551,6 +589,25 @@ describe('useSearchControlsHandlers', () => {
expect(resetCurrentlyPreviewedEntityBfid).toHaveBeenCalled();
});

it('skips preview management while configured not to on reset', () => {
const { result } = renderHook(() =>
useSearchControlsHandlers({
coreConfig: mockConfig,
uiConfig: mockUIConfig,
flow: 'url',
managePreview: false,
}),
);

act(() => {
result.current.onReset();
});

expect(resetPreviewContent).not.toHaveBeenCalled();
expect(resetFullDisplayComponentType).not.toHaveBeenCalled();
expect(resetCurrentlyPreviewedEntityBfid).not.toHaveBeenCalled();
});

it('sets default source in navigation state when segment has a default source', () => {
setInitialGlobalState([
{
Expand Down
14 changes: 8 additions & 6 deletions src/features/search/ui/hooks/useSearchControlsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface UseSearchControlsHandlersParams {
};
refetch?: () => Promise<void>;
onSubmitCallback?: () => void;
managePreview?: boolean;
}

interface SearchControlsHandlers {
Expand Down Expand Up @@ -115,6 +116,7 @@ export const useSearchControlsHandlers = ({
results,
refetch,
onSubmitCallback,
managePreview = true,
}: UseSearchControlsHandlersParams): SearchControlsHandlers => {
const [searchParams, setSearchParams] = useSearchParams();

Expand Down Expand Up @@ -222,9 +224,7 @@ export const useSearchControlsHandlers = ({
saveCurrentDraft();

// Reset preview
resetPreviewContent();
resetFullDisplayComponentType();
resetCurrentlyPreviewedEntityBfid();
resetPreview();

// Resolve configs for the new segment using centralized resolvers
const newSegmentConfig = resolveCoreConfig(newSegment);
Expand Down Expand Up @@ -313,9 +313,11 @@ export const useSearchControlsHandlers = ({
);

const resetPreview = () => {
resetPreviewContent();
resetFullDisplayComponentType();
resetCurrentlyPreviewedEntityBfid();
if (managePreview) {
resetPreviewContent();
resetFullDisplayComponentType();
resetCurrentlyPreviewedEntityBfid();
}
};

const handleSubmit = useCallback(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/features/search/ui/providers/SearchProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function isDynamicMode(props: SearchProviderProps): props is SearchProviderProps
}

export const SearchProvider: FC<SearchProviderProps> = props => {
const { flow, mode = 'custom', children, onSubmitCallback } = props;
const { flow, mode = 'custom', children, onSubmitCallback, managePreview } = props;
const { isLoading: isGlobalLoading } = useLoadingState(['isLoading']);

// Extract dynamic/static mode params
Expand Down Expand Up @@ -73,6 +73,7 @@ export const SearchProvider: FC<SearchProviderProps> = props => {
results,
refetch,
onSubmitCallback,
managePreview,
});

// Sync URL to store (URL flow only)
Expand Down
1 change: 1 addition & 0 deletions src/features/search/ui/types/provider.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ interface BaseProviderProps {
mode?: RenderMode;
children: React.ReactNode;
onSubmitCallback?: () => void;
managePreview?: boolean;
}

export type SearchProviderProps = BaseProviderProps & (StaticModeProps | DynamicModeProps);
Loading