mirror of
https://github.com/fergalmoran/turnstone.git
synced 2025-12-22 09:49:56 +00:00
Prevent no items message from displaying whilst items are being fetched
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user