Skip to content

Commit cc225b6

Browse files
committed
fix(select): not using string types
1 parent 8efa579 commit cc225b6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/utils/settings/types/select.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import toArray from '../../toArray.js';
12
import { translateText } from '../../translate.js';
23
import Setting from './text.js';
34

@@ -7,8 +8,8 @@ export default class Select extends Setting {
78
}
89

910
default([data] = []) {
10-
const [l, v = l] = Array.isArray(data) ? data : [data];
11-
return v;
11+
const [l, v = l] = toArray(data);
12+
return `${v}`;
1213
}
1314

1415
element(value, update, {
@@ -22,7 +23,7 @@ export default class Select extends Setting {
2223

2324
function options(data = [], current = '') {
2425
return data.map((o) => {
25-
const [l, v = l] = Array.isArray(o) ? o : [o];
26-
return `<option value="${v}"${current === v ? ' selected' : ''}>${translateText(l)}</option>`;
26+
const [l, v = l] = toArray(o);
27+
return `<option value="${v}"${current === `${v}` ? ' selected' : ''}>${translateText(l)}</option>`;
2728
});
2829
}

src/utils/toArray.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function toArray(value = []) {
2+
return Array.isArray(value) ? value : [value];
3+
}

0 commit comments

Comments
 (0)