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

Make element-search-dialog easier to customize #430

Merged
merged 14 commits into from
May 17, 2024

Conversation

klesaulnier
Copy link
Contributor

No description provided.

LE SAULNIER Kevin added 4 commits May 2, 2024 10:13
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
@klesaulnier klesaulnier requested a review from sBouzols May 3, 2024 09:53
renderElement,
searchTermDisabled,
searchTermDisableReason,
isLoading,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to expose this prop to the owner of ElementSearchDialog ?
Maybe we could set a local state to true when onSearchTermChange is called then set it to false when elementsFound changes ?
I think It's complex if we let the component owner manage this state no ?
At least name is loading as the Autocomplete prop ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's way better to handle "isLoading" when we make the fetch, otherwise we will have some troubles handling errors or edge cases

for "isLoading" naming, I see your point, but I think it's more clear to call it "isLoading"
Can we ask a 3rd person to decide with us ?

Copy link
Contributor

Choose a reason for hiding this comment

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

?on which case we can have troubles or errors when using state instead of props

@sBouzols
Copy link
Contributor

sBouzols commented May 7, 2024

When testing I saw that we show the "loading..." text when input field is empty (enter a character, then remove it), that doesn't happen at the moment in gridstudy

@klesaulnier
Copy link
Contributor Author

When testing I saw that we show the "loading..." text when input field is empty (enter a character, then remove it), that doesn't happen at the moment in gridstudy

Before, emptying the field would make the suggestions empty, now we are displaying the history
But you're right, maybe we should display them without having to way for the debounce to actually execute if the use input is empty

@sBouzols
Copy link
Contributor

When testing I saw that we show the "loading..." text when input field is empty (enter a character, then remove it), that doesn't happen at the moment in gridstudy

Before, emptying the field would make the suggestions empty, now we are displaying the history But you're right, maybe we should display them without having to way for the debounce to actually execute if the use input is empty

Yex I think it could be a problem if we fetch something with an empty string you know.
I think we want to avoid this for any onSearchTermChange callback prop then maybe just don't call it in this component if searchTerm is empty ?
image

Comment on lines +54 to +56
return searchTermDisabled || searchTermDisableReason
? searchTermDisableReason
: searchTerm;
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
return searchTermDisabled || searchTermDisableReason
? searchTermDisableReason
: searchTerm;
return searchTermDisabled
? searchTermDisableReason
: searchTerm;

Copy link
Contributor

Choose a reason for hiding this comment

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

and add a default value for searchTermDisableReason maybe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I'm not sure here, he we could have a behaviour where searchTermDisabled is "true" and searchTermDisableReason is empty

It means we would disable the component, but still display "searchTerm" in the textInput

This was the previous behaviour if I'm not wrong

src/hooks/useDebounce.ts Show resolved Hide resolved
sBouzols and others added 2 commits May 14, 2024 12:22
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
@klesaulnier klesaulnier requested a review from sBouzols May 15, 2024 14:31
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Copy link
Contributor

@sBouzols sBouzols left a comment

Choose a reason for hiding this comment

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

Code Review OK
Test OK
Console warning check OK

@klesaulnier klesaulnier merged commit cff545c into main May 17, 2024
3 checks passed
@klesaulnier klesaulnier deleted the refacto-element-search-dialog branch May 17, 2024 10:19
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.

None yet

3 participants