freenowtech / freenowtech/wave

Applying custom styling to SelectList component overrides other styling

Open
#219 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
67
Forks
31
Avg merge
1d 8h
Merged PRs (30d)
4

Description

- `@freenow/wave` version: 1.18.0

### Relevant code

When applying custom styles to the SelectList component using the [styles API from react-select](https://react-select.com/styles#style-object), other styles get overwritten.

For example:

```js
({
...css,
position: 'relative',
...(state.isSelected && {
'::after': {
content: '" (selected)"',
},
}),
}),
}}
label="City"
onChange={change => console.log(change)}
options={[
{
label: 'Barcelona',
value: 'bcn',
},
{
label: 'Hamburg',
value: 'ham',
},
{
label: 'Paris',
value: 'par',
isDisabled: true,
},
]}
/>
```

Produces a select list that looks like this, where the style is overwritten for the pills, disabled state, height of the select list...

Screenshot 2022-05-03 at 11 34 49

Our use case for applying custom styling to the option is that we want to show the "(selected)" text next to the selected ones, to help the user navigate the options. We are currently doing this with JS, but we can simplify the code a lot if custom css was supported here.

### What was expected to happen?

Styles should be merged?

### Reproduction

https://codesandbox.io/s/wave-playground-forked-oq8jpd?file=/src/App.js

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.