Skip to content

Commit 3286c3e

Browse files
committed
refactor: simplify shownOptions
1 parent 91da90c commit 3286c3e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/components/light-search-bar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ const LightSearchBar = () => {
209209
const onChange = itemID => setValue(itemID)
210210

211211
const shownOptions = () => {
212-
if ((writing || itemSearchQuery.loading) && !empty)
212+
if (empty) return []
213+
if (writing || itemSearchQuery.loading)
213214
return <Select.Option key="Loading">Loading...</Select.Option>
214-
if (!writing && options.length === 0 && !empty)
215+
if (!writing && options.length === 0)
215216
return <Select.Option key="NoResult">No results</Select.Option>
216-
if (empty) return []
217217
else return options
218218
}
219219

src/components/search-bar.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,10 @@ const SearchBar = () => {
301301
const onChange = useCallback(itemID => setValue(itemID), [])
302302

303303
const shownOptions = () => {
304-
if (writing && !empty)
305-
return <Select.Option key="Loading">Loading...</Select.Option>
306-
if (!writing && options.length === 0 && !empty)
307-
return <Select.Option key="NoResult">No results</Select.Option>
308304
if (empty) return []
305+
if (writing) return <Select.Option key="Loading">Loading...</Select.Option>
306+
if (!writing && options.length === 0)
307+
return <Select.Option key="NoResult">No results</Select.Option>
309308
else return options
310309
}
311310

0 commit comments

Comments
 (0)