Skip to content

Commit

Permalink
fix(Select): options have wrong styling when field is over inverse va…
Browse files Browse the repository at this point in the history
…riant (#1024)
  • Loading branch information
marcoskolodny authored Feb 16, 2024
1 parent dff56b2 commit fc7849f
Show file tree
Hide file tree
Showing 5 changed files with 244 additions and 187 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/__screenshot_tests__/form-select-screenshot-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ test('Select - display all options', async () => {
expect(image).toMatchImageSnapshot();
});

test('Select - display all options over inverse', async () => {
const page = await openStoryPage({
id: 'components-select--controlled',
device: 'DESKTOP',
args: {inverse: true},
});

const field = await screen.findByRole('button', {name: 'Select a fruit'});
await field.click();

const image = await page.screenshot();

expect(image).toMatchImageSnapshot();
});

test('Select - display all options with native select', async () => {
const page = await openStoryPage({
id: 'components-select--controlled',
Expand All @@ -165,3 +180,18 @@ test('Select - display all options with native select', async () => {

expect(image).toMatchImageSnapshot();
});

test('Select - display all options with native select over inverse', async () => {
const page = await openStoryPage({
id: 'components-select--controlled',
device: 'DESKTOP',
args: {native: true, inverse: true},
});

const field = await screen.findByLabelText('Select a fruit');
await field.click();

const image = await page.screenshot();

expect(image).toMatchImageSnapshot();
});
76 changes: 48 additions & 28 deletions src/__stories__/select-story.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as React from 'react';
import {fruitEntries} from './helpers';
import {Select} from '..';
import {Box, ResponsiveLayout, Select} from '..';

export default {
title: 'Components/Select',
component: Select,
parameters: {fullScreen: true},
};

type Args = {
Expand All @@ -14,6 +15,7 @@ type Args = {
error: boolean;
native: boolean;
optional: boolean;
inverse: boolean;
};

const defaultArgs = {
Expand All @@ -23,29 +25,42 @@ const defaultArgs = {
error: false,
native: false,
optional: false,
inverse: false,
};

export const Controlled: StoryComponent<Args> = ({label, helperText, disabled, error, native, optional}) => {
export const Controlled: StoryComponent<Args> = ({
label,
helperText,
disabled,
error,
native,
optional,
inverse,
}) => {
const fruitOptions = fruitEntries.map(([text, value]) => ({text, value}));
fruitOptions.push({value: 'longValue', text: 'A very very long text value for this option'});

const [value, setValue] = React.useState('');

return (
<div data-testid="select-field-wrapper" style={{width: 'fit-content'}}>
<Select
name="select-field"
native={native}
error={error}
disabled={disabled}
optional={optional}
value={value}
onChangeValue={setValue}
label={label}
helperText={helperText}
options={fruitOptions}
/>
</div>
<ResponsiveLayout isInverse={inverse} fullWidth>
<Box padding={16}>
<div data-testid="select-field-wrapper" style={{width: 'fit-content'}}>
<Select
name="select-field"
native={native}
error={error}
disabled={disabled}
optional={optional}
value={value}
onChangeValue={setValue}
label={label}
helperText={helperText}
options={fruitOptions}
/>
</div>
</Box>
</ResponsiveLayout>
);
};

Expand All @@ -59,23 +74,28 @@ export const Uncontrolled: StoryComponent<Args> = ({
error,
native,
optional,
inverse,
}) => {
const fruitOptions = fruitEntries.map(([text, value]) => ({text, value}));
fruitOptions.push({value: 'longValue', text: 'A very very long text value for this option'});

return (
<div data-testid="select-field-wrapper" style={{width: 'fit-content'}}>
<Select
name="select-field"
native={native}
error={error}
disabled={disabled}
optional={optional}
label={label}
helperText={helperText}
options={fruitOptions}
/>
</div>
<ResponsiveLayout isInverse={inverse} fullWidth>
<Box padding={16}>
<div data-testid="select-field-wrapper" style={{width: 'fit-content'}}>
<Select
name="select-field"
native={native}
error={error}
disabled={disabled}
optional={optional}
label={label}
helperText={helperText}
options={fruitOptions}
/>
</div>
</Box>
</ResponsiveLayout>
);
};

Expand Down
Loading

1 comment on commit fc7849f

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for mistica-web ready!

✅ Preview
https://mistica-2q0l8j6ec-tuentisre.vercel.app

Built with commit fc7849f.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.