Skip to content

Commit

Permalink
feat(query-bar): expand options when applied from query history with …
Browse files Browse the repository at this point in the history
…options (#5889)
  • Loading branch information
Anemy authored Jun 11, 2024
1 parent 8aa170f commit 3835b6f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/compass-query-bar/src/stores/query-bar-reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,21 @@ describe('queryBarReducer', function () {
'{ _id: -1 }'
);
});

it('should auto expand when the query contains extra options', function () {
const queryNoExtraOptions = {
filter: { _id: 2 },
};
store.dispatch(applyFromHistory(queryNoExtraOptions));
expect(store.getState().queryBar.expanded).to.be.false;

const queryWithExtraOptions = {
filter: { _id: 2 },
sort: { _id: -1 },
};
store.dispatch(applyFromHistory(queryWithExtraOptions));
expect(store.getState().queryBar.expanded).to.be.true;
});
});

describe('isReadonlyConnection', function () {
Expand Down
1 change: 1 addition & 0 deletions packages/compass-query-bar/src/stores/query-bar-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ export const queryBarReducer: Reducer<QueryBarState> = (
) {
return {
...state,
expanded: state.expanded || doesQueryHaveExtraOptionsSet(action.fields),
fields: action.fields,
};
}
Expand Down

0 comments on commit 3835b6f

Please sign in to comment.