fix: #297 input loses focus when changing isLoading #298
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue was caused by the
Inputbeing wrapped by anInputGroupwhen the loading state needed to be shown and not being wrapped by anInputGroupwhen the loading state did not need to be shown.This would cause the
Inputto lose focus causing a bad UX. We will now always render anInputGroupand pass theendElementprop based on theisLoadingprop.For consideration:
If you have a custom icon being displayed, the loading state will still display correctly but it looks weird because you will have 2 icons on top of each other. Because of this, I am considering removing the
isLoadingandloadingStateprops in v7. These should probably be external concerns that the users control themselves.For what it's worth, the Chakra UI
Comboboxcomponent functions this way where the loading state is something controlled and displayed externally.https://chakra-ui.com/docs/components/combobox#async-loading
This fixes #297