Capgemini / dcx-react-library

React Library UI/UX agnostic
https://main--6069a6f47f4b9f002171f8e1.chromatic.com
MIT License
107 stars 7 forks source link

The autocomplete component needs to be split into two separate components #637

Open alexwbbr opened 2 months ago

alexwbbr commented 2 months ago

The autocomplete component is currently just over 700 lines long and handles multiselect, loading of the options dynamically with the use of onChange and using static options which are then either filtered inside the autocomplete or with an external function using the search parameter. The reason for this refactor would be to reduce the code complexity and hopefully the size of the components so that they are easier to work on in the future.

The two new components would be DynamicAutocomplete and StaticAutoComplete, the main difference between the two components is how they handle filtering and the loading of options. The dynamic autocomplete would have all filtering external to the component, done by the user, and the user would then update the options property to give the new results. Whereas the static autocomplete options property never changes it's value after it has received the data. The filtering can be done either externally or internally to the component however the options value is never updated by the user.

These two components would still need to handle the current functionality of switching to a form select if the user has turned off javascript and all of the accessibility features that have been added recently. The two components would NOT include the multiselect functionality which would be split off into it's own component in a separate ticket.

Tasks

Please follow these steps to create your branch:

git checkout release/1.1.0
git pull
git checkout -b 'feature/split-autocomplete'
alexsteele95 commented 1 week ago

Looking into this