Skip to content

Commit 8f8a735

Browse files
authored
Fix [Form select] show label instead of value (#37)
1 parent ba327df commit 8f8a735

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

src/lib/components/FormCheckBox/formCheckBox.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
input[type='checkbox'] {
1111
@include radioCheckField;
1212

13+
flex: 0 0 18px;
1314
width: 18px;
1415
height: 18px;
1516
border-radius: 4px;

src/lib/components/FormSelect/FormSelect.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ const FormSelect = ({
6363
return !multiple
6464
? selectedOption?.label
6565
: input.value.length <= 2
66-
? input.value.join(', ')
66+
? options
67+
.filter((option) => input.value.includes(option.id))
68+
.map((option) => option.label)
69+
.join(', ')
6770
: `${input.value.length} items selected`
6871
}
6972

@@ -293,7 +296,6 @@ FormSelect.defaultProps = {
293296
disabled: false,
294297
hideSelectedOption: false,
295298
label: '',
296-
labelAtTop: false,
297299
onClick: null,
298300
search: false,
299301
multiple: false,
@@ -307,7 +309,6 @@ FormSelect.propTypes = {
307309
disabled: PropTypes.bool,
308310
hideSelectedOption: PropTypes.bool,
309311
label: PropTypes.string,
310-
labelAtTop: PropTypes.bool,
311312
name: PropTypes.string.isRequired,
312313
onClick: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
313314
options: SELECT_OPTIONS.isRequired,

src/lib/components/FormSelect/formSelect.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
.pop-up-dialog {
6767
width: 100%;
6868
padding: 0;
69+
border-radius: 0;
6970

7071
&__header {
7172
display: none;
@@ -79,7 +80,7 @@
7980
color: $mulledWineTwo;
8081
background-color: $white;
8182
border: $primaryBorder;
82-
border-radius: 2px;
83+
border-radius: 4px;
8384
box-shadow: $filterShadow;
8485
}
8586

src/lib/elements/SelectOption/SelectOption.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ import './selectOption.scss'
1313
const SelectOption = ({ item, name, onClick, multiple, selectedId, withSelectedIcon }) => {
1414
const selectClassName = classnames(
1515
'select__item',
16+
multiple && 'multiple',
1617
item.hidden && 'hidden',
1718
item.disabled && 'disabled'
1819
)
1920
if (multiple) {
2021
return (
2122
<div data-testid="select-checkbox" className={selectClassName}>
22-
<FormCheckBox name={name} id={item.id} value={item.id} label={item.label}>
23+
<FormCheckBox name={name} value={item.id} label={item.label}>
2324
{item.status && <span className={`state-${item.status}-job status`} />}
2425
</FormCheckBox>
2526
</div>
2627
)
2728
}
29+
2830
return (
2931
<div
3032
data-testid="select-option"
@@ -65,6 +67,7 @@ SelectOption.defaultProps = {
6567

6668
SelectOption.propTypes = {
6769
disabled: PropTypes.bool,
70+
name: PropTypes.string.isRequired,
6871
item: SELECT_OPTION.isRequired,
6972
onClick: PropTypes.func,
7073
multiple: PropTypes.bool,

src/lib/elements/SelectOption/selectOption.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
min-height: 49px;
88
padding: 16px 15px;
99

10+
&.multiple {
11+
padding: 0 15px;
12+
min-height: 0;
13+
14+
input[type='checkbox'] ~ label {
15+
padding-top: 16px;
16+
padding-bottom: 16px;
17+
}
18+
}
19+
1020
&.hidden {
1121
display: none;
1222
}

0 commit comments

Comments
 (0)