@loadsmart/loadsmart-ui 5.8.0 → 5.8.1

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.0",
3
+ "version": "5.8.1",
4
4
  "description": "Miranda UI, a React UI library",
5
5
  "main": "dist",
6
6
  "files": [
@@ -12,6 +12,7 @@ import selectEvent from '../../testing/SelectEvent'
12
12
  import type { SelectProps, Option, GenericOption } from './Select.types'
13
13
  import Select from './Select'
14
14
  import userEvent from '@testing-library/user-event'
15
+ import type { Selectable } from 'hooks/useSelectable'
15
16
 
16
17
  const {
17
18
  Playground,
@@ -854,6 +855,32 @@ describe('Select', () => {
854
855
  expect(options[options.length - 1]).toHaveTextContent(/add ""/i)
855
856
  }
856
857
  )
858
+
859
+ it.each([[{ multiple: false }], [{ multiple: true }]])(
860
+ 'keep creatable option on the list even when any value is selected - %s',
861
+ async (args) => {
862
+ const CreatableOption = () => {
863
+ return (
864
+ <Select.CreatableOption data-testid="custom-creatable">Add item</Select.CreatableOption>
865
+ )
866
+ }
867
+
868
+ const value = generator.pickone(FRUITS) as Selectable
869
+
870
+ setup({
871
+ ...args,
872
+ isValidNewOption: true,
873
+ createOptionPosition: 'first',
874
+ value,
875
+ components: {
876
+ CreatableOption,
877
+ },
878
+ })
879
+
880
+ await expandSelect(true)
881
+ expect(await screen.findByText(/add item/i)).toBeVisible()
882
+ }
883
+ )
857
884
  })
858
885
 
859
886
  describe('Creatable Async', () => {
@@ -432,18 +432,13 @@ function useSelect(props: SelectProps): useSelectReturn {
432
432
 
433
433
  function getIsValidNewOption() {
434
434
  if (isFunction(isValidNewOption)) {
435
- return isValidNewOption(query)
435
+ return isValidNewOption(query) && !isQueryEqualAnOption()
436
436
  }
437
437
 
438
438
  return isValidNewOption
439
439
  }
440
440
 
441
- return (
442
- isFunction(onCreate) &&
443
- getIsValidNewOption() &&
444
- options.status === 'queried' &&
445
- !isQueryEqualAnOption()
446
- )
441
+ return isFunction(onCreate) && options.status === 'queried' && getIsValidNewOption()
447
442
  },
448
443
  [getSelectableOption, isValidNewOption, onCreate, options, query, selectable.selected]
449
444
  )