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

fix(element-search): remove freesolo and improve typing #456

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

Conversation

TheMaskedTurtle
Copy link
Contributor

@TheMaskedTurtle TheMaskedTurtle commented May 23, 2024

freesolo is not the wished behavior for the element search bar so we can remove it, it simplifies component typing.

@@ -54,8 +53,8 @@ const ElementSearchDialog = (props: ElementSearchDialogProps) => {

const displayedValue = useMemo(() => {
return searchTermDisabled || searchTermDisableReason
? searchTermDisableReason
: searchTerm;
? searchTermDisableReason ?? 'search disabled'
Copy link
Contributor

Choose a reason for hiding this comment

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

manage translation for this default value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// we don't want to change "searchTerm" when clicking a result
if (!searchTermDisabled && reason !== 'reset') {
onInputChange={(_event, value) => {
if (!searchTermDisabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

must restore reason to avoid calling onSearchTermChange when selecting an option. Otherwise it will fetch serach one more time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@TheMaskedTurtle TheMaskedTurtle force-pushed the jorism/remove-free-solo branch from 5f5748a to ef23da5 Compare June 3, 2024 12:49
@TheMaskedTurtle TheMaskedTurtle requested a review from sBouzols June 5, 2024 07:50
Comment on lines +56 to +61
? searchTermDisableReason ??
intl.formatMessage({
id: 'element_search/searchDisabled',
})
: searchTerm ?? '';
}, [searchTermDisabled, searchTermDisableReason, intl, searchTerm]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is usually not a good pratice to add complexity to ternary.
you probably need to change to if/else statement

Copy link

sonarqubecloud bot commented Sep 2, 2024

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