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(components): show an info element on mutation filter #157 #181

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ const submitMutation = async (canvas: ReturnType<typeof within>, mutation: strin
await userEvent.type(inputField(canvas), mutation);
await waitFor(() => submitButton(canvas).click());
};
const inputField = (canvas: ReturnType<typeof within>) => canvas.getByPlaceholderText('Enter a mutation');
const inputField = (canvas: ReturnType<typeof within>) =>
canvas.getByPlaceholderText('Enter a mutation', { exact: false });
const submitButton = (canvas: ReturnType<typeof within>) => canvas.getByRole('button', { name: '+' });
16 changes: 10 additions & 6 deletions components/src/preact/mutationFilter/mutation-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useContext, useRef, useState } from 'preact/hooks';
import { parseAndValidateMutation } from './parseAndValidateMutation';
import { type Deletion, type Insertion, type Mutation, type Substitution } from '../../utils/mutations';
import { ReferenceGenomeContext } from '../ReferenceGenomeContext';
import Info from '../components/info';
import { singleGraphColorRGBByName } from '../shared/charts/colors';
import { DeleteIcon } from '../shared/icons/DeleteIcon';

Expand Down Expand Up @@ -83,11 +84,14 @@ export const MutationFilter: FunctionComponent<MutationFilterProps> = () => {

return (
<div class={`rounded-lg border border-gray-300 bg-white p-2`}>
<SelectedMutationDisplay
selectedFilters={selectedFilters}
setSelectedFilters={setSelectedFilters}
fireChangeEvent={fireChangeEvent}
/>
<div class='flex justify-between'>
<SelectedMutationDisplay
selectedFilters={selectedFilters}
setSelectedFilters={setSelectedFilters}
fireChangeEvent={fireChangeEvent}
/>
<Info className='mx-1' content='Info for mutation filter' />
</div>

<form className='mt-2 w-full' onSubmit={handleSubmit} ref={formRef}>
<label className={`input flex items-center gap-2 ${isError ? 'input-error' : 'input-bordered'}`}>
Expand All @@ -96,7 +100,7 @@ export const MutationFilter: FunctionComponent<MutationFilterProps> = () => {
type='text'
value={inputValue}
onInput={handleInputChange}
placeholder={'Enter a mutation'}
placeholder={'Enter a mutation (e.g. A123T, ins_123:AT, S:M123E, ins_S:123:ME)'}
onBlur={handleOnBlur}
/>
<button className='btn btn-sm'>+</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const FiresFilterChangedEvent: StoryObj<{ lapisField: string; placeholder
play: async ({ canvasElement, step }) => {
const canvas = await withinShadowRoot(canvasElement, 'gs-mutation-filter');

const inputField = () => canvas.getByPlaceholderText('Enter a mutation');
const inputField = () => canvas.getByPlaceholderText('Enter a mutation', { exact: false });
const submitButton = () => canvas.getByRole('button', { name: '+' });
const listenerMock = fn();
await step('Setup event listener mock', async () => {
Expand Down Expand Up @@ -75,7 +75,7 @@ export const FiresFilterOnBlurEvent: StoryObj<{ lapisField: string; placeholderT
play: async ({ canvasElement, step }) => {
const canvas = await withinShadowRoot(canvasElement, 'gs-mutation-filter');

const inputField = () => canvas.getByPlaceholderText('Enter a mutation');
const inputField = () => canvas.getByPlaceholderText('Enter a mutation', { exact: false });
const listenerMock = fn();
await step('Setup event listener mock', async () => {
canvasElement.addEventListener('gs-mutation-filter-on-blur', listenerMock);
Expand Down