Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复级联选择器数据源异常label为数组时页面崩溃的问题 #10836

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading