Skip to content

Commit

Permalink
fix: 修复级联选择器数据源异常label为数组时页面崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jinye committed Aug 27, 2024
1 parent 6eab370 commit 0741cd4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/amis/src/renderers/Form/NestedSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import {
ActionObject,
renderTextByKeyword,
getVariable,
TestIdBuilder
TestIdBuilder,
labelToString
} from 'amis-core';
import {findDOMNode} from 'react-dom';
import xor from 'lodash/xor';
Expand Down Expand Up @@ -250,15 +251,17 @@ export default class NestedSelectControl extends React.Component<
const regexp = string2regExp(inputValue);

if (hideNodePathLabel) {
return option[labelField || 'label'];
return labelToString(option[labelField || 'label']);
}
const ancestors = getTreeAncestors(options, option, true);

const optionText = option[labelField || 'label'];
const optionText = labelToString(option[labelField || 'label']);
const splitJoin = ' / ';

const title = ancestors
? ancestors.map(item => item[labelField || 'label']).join(splitJoin)
? ancestors
.map(item => labelToString(item[labelField || 'label']))
.join(splitJoin)
: optionText;

return (
Expand All @@ -269,7 +272,7 @@ export default class NestedSelectControl extends React.Component<
>
{ancestors
? ancestors.map((item, index) => {
const label = item[labelField || 'label'];
const label = labelToString(item[labelField || 'label']);
const value = item[valueField || 'value'];
const isEnd = index === ancestors.length - 1;
return (
Expand Down Expand Up @@ -709,7 +712,7 @@ export default class NestedSelectControl extends React.Component<
selfChecked = true;
}

let label = option[labelField || 'label'];
let label = labelToString(option[labelField || 'label']);

return (
<div
Expand Down

0 comments on commit 0741cd4

Please sign in to comment.