diff --git a/packages/compass-query-bar/src/stores/query-bar-reducer.spec.ts b/packages/compass-query-bar/src/stores/query-bar-reducer.spec.ts index 3bc17ec995c..bc8b8e2e5db 100644 --- a/packages/compass-query-bar/src/stores/query-bar-reducer.spec.ts +++ b/packages/compass-query-bar/src/stores/query-bar-reducer.spec.ts @@ -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 () { diff --git a/packages/compass-query-bar/src/stores/query-bar-reducer.ts b/packages/compass-query-bar/src/stores/query-bar-reducer.ts index f343e3053be..71da0837305 100644 --- a/packages/compass-query-bar/src/stores/query-bar-reducer.ts +++ b/packages/compass-query-bar/src/stores/query-bar-reducer.ts @@ -519,6 +519,7 @@ export const queryBarReducer: Reducer = ( ) { return { ...state, + expanded: state.expanded || doesQueryHaveExtraOptionsSet(action.fields), fields: action.fields, }; }