-
Notifications
You must be signed in to change notification settings - Fork 4
Variation search #1229
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
base: main
Are you sure you want to change the base?
Variation search #1229
Conversation
export enum FeatureSearchModeType { | ||
GENE_SEARCH_MODE = 'Gene', | ||
VARIANT_SEARCH_MODE = 'Variant' | ||
} |
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.
Let's not use enums. Enums are an early typescript feature that doesn't have a direct correspondence in javascript, and that comes with various problems.
VARIANT_SEARCH_MODE = 'Variant' | ||
} | ||
|
||
export const FEATURE_SEARCH_MODES: FeatureSearchMode[] = [ |
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.
If it is a const, why does it live in a types file?
onClick={() => updateActiveFeatureSearchMode(searchMode)} | ||
> | ||
{searchMode.label} | ||
</TextButton> |
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.
Disable the button when the search mode is active. You aren't doing this currently, and as a result, the button can still be focused.
type Props = { | ||
query: string; | ||
activeFeatureSearchMode: FeatureSearchMode; | ||
searchLocation?: string; // Ex: 'sidebar', 'interstitial' |
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.
To me, this property name is confusing. If its purpose is to convey the context in which the component renders, then perhaps position
, or variety
, or something of that sort.
Also, why is it optional, and why is it a generic string, rather than just the two possible values?
searchLocation?: string; // Ex: 'sidebar', 'interstitial' | ||
onSearchSubmit: (query: string) => void; | ||
onClear: () => void; | ||
updateActiveFeatureSearchMode: (mode: FeatureSearchMode) => void; |
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.
updateActiveFeatureSearchMode
-> onSearchModeChange
|
||
type Props = { | ||
query: string; | ||
activeFeatureSearchMode: FeatureSearchMode; |
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.
I wonder if either all 'feature search modes' should come from outside of the component, or the passed in active mode should just be a string. It feels that it should only just be a string.
setSearchInput(query); | ||
setShouldDisableSubmit(true); | ||
} | ||
}, [query]); |
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.
You will see things like this all over the codebase (my fault), but React team thinks that this is actually bad. If an effect is used for the sole purpose to update the state, then the state should be updated as part of render instead.
https://react.dev/reference/eslint-plugin-react-hooks/lints/set-state-in-effect
As a part of some future pull request, we should try to update the linter rules, and address the errors. There will be plenty 😞
wip