Skip to content

Conversation

@shashankbrgowda
Copy link
Contributor

@shashankbrgowda shashankbrgowda commented Oct 9, 2025

Details

UI to search for variants in species selector, app interstitial and sidebar search page.

export enum FeatureSearchModeType {
GENE_SEARCH_MODE = 'Gene',
VARIANT_SEARCH_MODE = 'Variant'
}
Copy link
Collaborator

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[] = [
Copy link
Collaborator

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>
Copy link
Collaborator

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'
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is being used to accommodate existing functionality in InAppSearch to apply necessary styles. Its optional because search form in species selector page doesn't need to apply any styles. The search form is now reused across species selector, Interstitial and sidebar.

searchLocation?: string; // Ex: 'sidebar', 'interstitial'
onSearchSubmit: (query: string) => void;
onClear: () => void;
updateActiveFeatureSearchMode: (mode: FeatureSearchMode) => void;
Copy link
Collaborator

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;
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Search modes are configuration driven so it contains different parameters necessary for form

setSearchInput(query);
setShouldDisableSubmit(true);
}
}, [query]);
Copy link
Collaborator

@azangru azangru Oct 10, 2025

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 😞

onClick: () => void;
label: string;
className?: string;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

If SearchButton becomes a very generic component:

  • Does it always need a label as a prop?
  • If we decide that it may exist without a label, should it in that case be able to have an aria-label for screen readers?
  • Could you add it to Storybook?

const { match, genomeIdForUrl } = props as {
match: GeneSearchMatch;
genomeIdForUrl: string;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

The type of props should probably be defined when the function is defined. It seems odd to be redefining the props type here.

getQueries: (state) => state.queries,
getGeneQuery: (state) => state.queries.gene,
getVariantQuery: (state) => state.queries.variant
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this selectors block is doing any work here. You defined the selectors in the speciesSelectorFeatureSearchSelectors file, and you are not exporting these selectors from this slice file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remind me: why are we keeping the state in a redux store? Why isn't it local to the component (or to the input DOM element)?

Copy link
Contributor Author

@shashankbrgowda shashankbrgowda Oct 16, 2025

Choose a reason for hiding this comment

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

I think I modified existing store. Helps to retain query state of both search modes during route change and reload.

@shashankbrgowda
Copy link
Contributor Author

shashankbrgowda commented Dec 16, 2025

For testing purpose ensembl search hub is deployed with test db

use rs6054257,rs624 and rs6040355 for testing with human genome a7335667-93e7-11ec-a39d-005056b38ce3

Test uri is configured in searchApiSlice.ts

curl --location 'http://infra-gitlab-runner:8000/api/search/variants' \
--header 'Content-Type: application/json' \
--data '{
    "query": "rs6054257",
    "genome_ids": [
        "a7335667-93e7-11ec-a39d-005056b38ce3"
    ],
    "page": 1,
    "per_page": 100
}'

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.

3 participants