Skip to content

Commit 86a7d26

Browse files
author
Kakuev
committed
fixed multi select issue
1 parent ce100b8 commit 86a7d26

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

dist/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function (_Component) {
174174
key: "handleCheck",
175175
value: function handleCheck(e) {
176176
this.setState({
177-
checked: e.target.id
177+
checked: e.target.value
178178
});
179179
this.props.action(e.target);
180180
}
@@ -195,12 +195,12 @@ function (_Component) {
195195
this.props.options.map(function (option, i) {
196196
options.push(React.createElement("label", {
197197
key: i,
198-
htmlFor: option.value,
198+
htmlFor: "".concat(option.name).concat(option.value),
199199
className: "single-option ".concat(_this2.state.checked === option.value ? 'checked-option' : '', " ").concat(option.disabled ? 'disabled-option' : ''),
200200
disabled: option.disabled
201201
}, React.createElement("input", {
202202
type: "radio",
203-
id: option.value,
203+
id: "".concat(option.name).concat(option.value),
204204
name: option.name,
205205
value: option.value,
206206
onChange: _this2.handleCheck,
@@ -211,11 +211,11 @@ function (_Component) {
211211
action: "",
212212
className: "flex justify-content-center align-items-center flex-column"
213213
}, options.length <= 4 && options, options.length > 4 && options.slice(0, 3), !this.state.showHidden && options.length > 4 && React.createElement("label", {
214-
htmlFor: "more",
214+
htmlFor: "".concat(options[0].name, "-more"),
215215
className: "single-option ".concat(this.state.checked === 'more' ? 'checked-option' : '')
216216
}, React.createElement("input", {
217217
type: "radio",
218-
id: "more",
218+
id: "".concat(options[0].name, "-more"),
219219
name: options[0].name,
220220
value: "more",
221221
onChange: this.openMore

src/components/OptionsList/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class OptionsList extends Component {
1313

1414
handleCheck(e) {
1515
this.setState({
16-
checked: e.target.id
16+
checked: e.target.value
1717
});
1818

1919
this.props.action(e.target);
@@ -31,15 +31,15 @@ class OptionsList extends Component {
3131
options.push(
3232
<label
3333
key={i}
34-
htmlFor={option.value}
34+
htmlFor={`${option.name}${option.value}`}
3535
className={`single-option ${this.state.checked === option.value
3636
? 'checked-option'
3737
: ''} ${option.disabled ? 'disabled-option' : ''}`}
3838
disabled={option.disabled}
3939
>
4040
<input
4141
type="radio"
42-
id={option.value}
42+
id={`${option.name}${option.value}`}
4343
name={option.name}
4444
value={option.value}
4545
onChange={this.handleCheck}
@@ -57,10 +57,16 @@ class OptionsList extends Component {
5757
{!this.state.showHidden &&
5858
options.length > 4 && (
5959
<label
60-
htmlFor="more"
60+
htmlFor={`${options[0].name}-more`}
6161
className={`single-option ${this.state.checked === 'more' ? 'checked-option' : ''}`}
6262
>
63-
<input type="radio" id="more" name={options[0].name} value="more" onChange={this.openMore} />
63+
<input
64+
type="radio"
65+
id={`${options[0].name}-more`}
66+
name={options[0].name}
67+
value="more"
68+
onChange={this.openMore}
69+
/>
6470
More
6571
</label>
6672
)}

0 commit comments

Comments
 (0)