Skip to content

Commit

Permalink
fix(select-input): Update for correct work with toString of object
Browse files Browse the repository at this point in the history
  • Loading branch information
EndyKaufman committed Mar 10, 2019
1 parent 3ddbb41 commit d72e27a
Showing 1 changed file with 2 additions and 8 deletions.
Expand Up @@ -18,9 +18,6 @@ export function keyToSelectInput(
if (options.idField === undefined) {
options.idField = 'id';
}
if (options.titleField === undefined) {
options.titleField = 'title';
}
const itemsIsEmpty = !options.items || options.items.length === 0;
if (itemsIsEmpty) {
options.items = [];
Expand All @@ -39,7 +36,7 @@ export function keyToSelectInput(
const transformedItems = options.items.map(
item => ({
id: item[options.idField],
title: item[options.titleField] || item,
title: options.titleField ? item[options.titleField] : (item || item['title'] || ''),
})
);
const items = keys.map(
Expand Down Expand Up @@ -70,9 +67,6 @@ export function selectInputToKey(
if (options.idField === undefined) {
options.idField = 'id';
}
if (options.titleField === undefined) {
options.titleField = 'title';
}
const itemsIsEmpty = !options.items || options.items.length === 0;
if (itemsIsEmpty) {
options.items = [];
Expand All @@ -88,7 +82,7 @@ export function selectInputToKey(
const transformedItems = options.items.map(
item => ({
id: item[options.idField],
title: item[options.titleField] || item
title: options.titleField ? item[options.titleField] : (item || item['title'] || '')
})
);
const keys = objects.map(
Expand Down

0 comments on commit d72e27a

Please sign in to comment.