Skip to content

Commit

Permalink
UIPQB-164: Columns are reset when user modifies query (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
UladzislauKutarkin authored Dec 27, 2024
1 parent 587aadb commit 5802dba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

* [UIPQB-141](https://folio-org.atlassian.net/browse/UIPQB-141) Modal dialog focus inconsistencies across screenreaders.
* [UIPQB-162](https://folio-org.atlassian.net/browse/UIPQB-162) Errors when query includes a modified custom field.
* [UIPQB-175](https://folio-org.atlassian.net/browse/UIPQB-175) Displays the "Smth went wrong" page, when the user clicks on "Select operator" dropdown and selects any of them, if there are deleted custom fields
* [UIPQB-175](https://folio-org.atlassian.net/browse/UIPQB-175) Displays the "Smth went wrong" page, when the user clicks on "Select operator" dropdown and selects any of them, if there are deleted custom fields.
* [UIPQB-164](https://folio-org.atlassian.net/browse/UIPQB-164) Columns are reset when user modifies query.

## [1.2.7](https://github.com/folio-org/ui-plugin-query-builder/tree/v1.2.7) (2024-12-26)

Expand Down
1 change: 1 addition & 0 deletions src/QueryBuilder/ResultViewer/ResultViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const ResultViewer = ({
onPreviewShown,
defaultLimit,
forcedVisibleValues,
visibleColumns,
});

// refresh functionality
Expand Down
4 changes: 2 additions & 2 deletions src/QueryBuilder/ResultViewer/ResultViewer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ describe('ResultViewer', () => {
});

describe('Initial and visible columns setters', () => {
it.each([[], undefined])('should call both when no initial fields are provided (recordColumns=%s)', async (visibleColumns) => {
render(renderResultViewer({ visibleColumns }));
it.each([[], undefined])('should call both when no initial fields are provided (recordColumns=%s)', async () => {
render(renderResultViewer({ visibleColumns: ['user_id'] }));

await waitFor(() => {
expect(screen.queryByText('ui-plugin-query-builder.viewer.retrieving')).not.toBeInTheDocument();
Expand Down
7 changes: 6 additions & 1 deletion src/hooks/useViewerCallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ export const useViewerCallbacks = ({
currentRecordsCount,
onPreviewShown,
defaultLimit,
visibleColumns,
}) => {
useEffect(() => {
if (defaultColumns.length !== 0) {
onSetDefaultColumns?.(defaultColumns);

onSetDefaultVisibleColumns?.(defaultVisibleColumns);
const uniqueVisibleColumns = Array.from(
new Set([...defaultVisibleColumns, ...visibleColumns]),
);

onSetDefaultVisibleColumns?.(uniqueVisibleColumns);
}
}, [currentRecordsCount]);

Expand Down

0 comments on commit 5802dba

Please sign in to comment.