@loadsmart/loadsmart-ui 5.8.1 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -881,6 +881,28 @@ describe('Select', () => {
|
|
|
881
881
|
expect(await screen.findByText(/add item/i)).toBeVisible()
|
|
882
882
|
}
|
|
883
883
|
)
|
|
884
|
+
|
|
885
|
+
it.each([[{ multiple: false }], [{ multiple: true }]])(
|
|
886
|
+
'show creatable option on the list even when option list is empty - %s',
|
|
887
|
+
async (args) => {
|
|
888
|
+
const CreatableOption = () => {
|
|
889
|
+
return <Select.CreatableOption>Add item</Select.CreatableOption>
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
setup({
|
|
893
|
+
...args,
|
|
894
|
+
isValidNewOption: true,
|
|
895
|
+
createOptionPosition: 'first',
|
|
896
|
+
options: [],
|
|
897
|
+
components: {
|
|
898
|
+
CreatableOption,
|
|
899
|
+
},
|
|
900
|
+
})
|
|
901
|
+
|
|
902
|
+
await expandSelect(true)
|
|
903
|
+
expect(await screen.findByText(/add item/i)).toBeVisible()
|
|
904
|
+
}
|
|
905
|
+
)
|
|
884
906
|
})
|
|
885
907
|
|
|
886
908
|
describe('Creatable Async', () => {
|
|
@@ -239,8 +239,14 @@ function useSelect(props: SelectProps): useSelectReturn {
|
|
|
239
239
|
const options = useOptions({ datasources, adapters })
|
|
240
240
|
|
|
241
241
|
const expandDisabled = useMemo(
|
|
242
|
-
() =>
|
|
243
|
-
|
|
242
|
+
() =>
|
|
243
|
+
!query.length &&
|
|
244
|
+
isEmpty(options.get()) &&
|
|
245
|
+
isEmpty(selectable.selected) &&
|
|
246
|
+
isFunction(isValidNewOption)
|
|
247
|
+
? !isValidNewOption(query)
|
|
248
|
+
: !isValidNewOption,
|
|
249
|
+
[query, options, selectable.selected, isValidNewOption]
|
|
244
250
|
)
|
|
245
251
|
|
|
246
252
|
const dropdown = useDropdown({ ...props, expandDisabled })
|