Prevent no items message from displaying whilst items are being fetched

This commit is contained in:
Tom Southall
2022-03-15 15:41:32 +00:00
parent aad534f187
commit cbe957195d
5 changed files with 7 additions and 6 deletions

View File

@@ -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

View File

@@ -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}

View File

@@ -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": [

View File

@@ -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:

View File

@@ -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
})
})