@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loadsmart/loadsmart-ui",
3
- "version": "5.8.1",
3
+ "version": "5.9.0",
4
4
  "description": "Miranda UI, a React UI library",
5
5
  "main": "dist",
6
6
  "files": [
@@ -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
- () => !query.length && isEmpty(options.get()) && isEmpty(selectable.selected),
243
- [query, options, selectable.selected]
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 })