Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a loading spinner in NLU prediction #648

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

TheCoderAdi
Copy link
Contributor

Motivation

This PR introduces a loading state to the Selectable component to improve the user experience while fetching NLP predictions. The CircularProgress spinner is displayed during API requests to indicate loading status.

Fixes issue: #638

Changes Made

  • Added a loading state in Selectable.tsx using useQuery with react-query.
  • Passed isLoading prop to the Selectable component for better state management.
  • Displayed a CircularProgress spinner inside Selectable when loading is true.
  • Ensured proper styling of the spinner to align correctly with the input field.

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@@ -205,6 +209,22 @@ const Selectable: FC<SelectableProps> = ({
onChange={(e) => handleTextChange(e.target.value)}
placeholder={placeholder}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
placeholder={placeholder}
placeholder={placeholder}
InputProps={{
endAdornment: loading ? (
<InputAdornment position="end">
<CircularProgress size={20} />
</InputAdornment>
) : null,
}}

I think you can add it as a adornment to the input.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I will do that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the TextField component, we can use InputProps to pass the endAdornment, but in the Input component, we need to use endAdornment directly. While using InputAdornment with TextField works as expected, it did not behave as intended when applied to Input.

To resolve this, I implemented custom CSS to properly position the spinner within the input field. After thorough testing across different devices, the solution is responsive and working as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @marrouchi ,
Any further changes needed ?

@TheCoderAdi TheCoderAdi requested a review from marrouchi February 3, 2025 14:21
Copy link
Collaborator

@IkbelTalebHssan IkbelTalebHssan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @TheCoderAdi for your contribution 🚀 👏
Left some minor comments

frontend/src/app-components/inputs/Selectable.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@yassinedorbozgithub yassinedorbozgithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please format the code by running this command
npm run lint:fix

Copy link
Collaborator

@yassinedorbozgithub yassinedorbozgithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @TheCoderAdi for being very responsive 🚀

@TheCoderAdi
Copy link
Contributor Author

Thank you @TheCoderAdi for being very responsive 🚀

Thanks! Looking forward to more feedback and improvements together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants