-
Notifications
You must be signed in to change notification settings - Fork 36
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
Adding error message in Search Comparison Tool #267
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
612cad7
adding error message in search comparison tool
sejli b075fd1
updating test snapshots
sejli fec1fe2
adding tests for query error
sejli e99ce99
updating tests
sejli d5cc342
refactoring QueryError, adding error message to result panel
sejli 2db8475
moving helper text to helpText prop
sejli a07402e
adding tests and addressing comments
sejli db6699e
adding more tests, fixing state management, addressing comments
sejli fb1b670
reverting changes to validateQuery, addressing comments
sejli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using functional forms of setState makes sense here to handle potential state consistency issue. For
validateQuery
andrewriteQuery
, if it's being refactor to pass state setter instead of the queryError object, the states are updated instantly. Is it a concern since they are helper functions ofonClickSearch
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: errorRepsonse -> errorResponse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Had a discussion offline, and we concluded that the
validateQuery
helper function does more than what it is supposed to do. Ideally, a validation function should only run validation logic, i.e. it should only returntrue
orfalse
and nothing else; the setting should be done in another function. Previously, a variable is passed intovalidateQuery
and then is set if it meets conditions. That variable is used later to set an error state. I believe that thevalidateQuery
should be used to returntrue
orfalse
in the function that sets states to avoid unnecessary stateful functions, and the error state should be set in a stateful function to maintain consistency. The code before my change seems to do this, will change it back to that.