diff --git a/CHANGELOG.md b/CHANGELOG.md index 161c3c4..7b72ef2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 1.1.2 (15 Mar 2022) +- Prevent no items message from displaying whilst items are being fetched + ### 1.1.2 (15 Mar 2022) - Add note to README regarding onSelect being called when an item is no longer selected diff --git a/examples/geo/App.jsx b/examples/geo/App.jsx index 57c12c3..57aba39 100644 --- a/examples/geo/App.jsx +++ b/examples/geo/App.jsx @@ -86,7 +86,6 @@ const App = () => { placeholder={placeholder} plugins={[[recentSearchesPlugin, {ratio: 2, name: 'Recent', limit: maxItems}]]} styles={autocompleteStyles} - text="bar" typeahead={true} Cancel={CancelButton} Clear={ClearButton} diff --git a/package.json b/package.json index bab3d5c..147469b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "turnstone", - "version": "1.1.2", + "version": "1.1.3", "description": "React customisable autocomplete component with typeahead and grouped results from multiple APIs.", "author": "Tom Southall", "keywords": [ diff --git a/src/lib/reducers/reducer.js b/src/lib/reducers/reducer.js index c67652b..5c1ff5b 100644 --- a/src/lib/reducers/reducer.js +++ b/src/lib/reducers/reducer.js @@ -14,7 +14,6 @@ const reducer = (state, action) => { switch (action.type) { case types.SET_QUERY: newState = { - canShowListbox: !!action.query.length, itemsError: false, query: action.query, selected: undef @@ -37,7 +36,8 @@ const reducer = (state, action) => { ? highlightedItem(0, action.items) : undef } - if(action.items.length) newState.canShowListbox = true + + if(state.query.length || action.items.length) newState.canShowListbox = true return newState case types.CLEAR: diff --git a/src/lib/reducers/reducer.test.js b/src/lib/reducers/reducer.test.js index ad65e63..43660a7 100644 --- a/src/lib/reducers/reducer.test.js +++ b/src/lib/reducers/reducer.test.js @@ -7,7 +7,6 @@ import { defaultListbox } from '../../../examples/_shared/defaultListbox' describe('SET_QUERY action', () => { test('produces expected new state', () => { const state = { - canShowListbox: false, itemsError: true, query: 'foo', selected: {index: 0, text: 'Foobar'}, @@ -19,7 +18,6 @@ describe('SET_QUERY action', () => { const action = actions.setQuery('bar') expect(reducer(state, action)).toEqual({ - canShowListbox: true, itemsError: false, query: 'bar', selected: undef, @@ -132,6 +130,7 @@ describe('SET_ITEMS action', () => { query: 'foo', items, itemsError: false, + canShowListbox: true, highlighted: undef }) })