Skip to content

refactor: Autocomplete component

Kheir Eddine requested to merge 1707-refactor-autocomplete into master

Closes #1707 (closed), Closes #1506 (closed)

In this refactoring the following props are changed:

  • ols is renamed to externalSources
  • optionsClass is renamed to includeClasses and changed the type to an array instead of a string.
  • cssClasses is removed and replaced with size that can take only the value sm for the moment.
  • autoLoadOption is not implimented, the autocomplete now always trigger the function loadOptions
  • handleCreateExistingLabel is removed, you can pass isValidNewOption as in react-select documented.
  • The props onItemSelected and onNewItemSelected are removed and you have to always use onChange because it insures the importing of external data when used.
  • onInput is removed and you can use onInputChange as in react-select documented.

For the typing, now all options are typed with OptionType but there is still some typing difficulties while passing the onChange props with takes the parameters forced by react-select.

onChange: (newValue: MultiValue<OptionType> | SingleValue<OptionType>, { action }: ActionMeta<OptionType>) => void

The following points from the issue are covered:

  • Move logic to API (ontology selection)
  • Clear on blur
  • Spreading props
  • Default value (to some extend) the component takes defaultValueId pros which can be the id of the entity but the value props should not be used (this can be improved)
  • Range restriction of literal values this can be incorporated in future once we have a use case.
Edited by Kheir Eddine

Merge request reports