mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 12:08:13 +08:00
fix: tree onRef属性不存在情况 (#3856)
This commit is contained in:
parent
8d4b1515fb
commit
98f3ff6b03
@ -210,7 +210,9 @@ export class TreeSelector extends React.Component<
|
||||
|
||||
componentDidMount() {
|
||||
const {enableNodePath} = this.props;
|
||||
this.props.onRef(this)
|
||||
|
||||
// onRef只有渲染器的情况才会使用
|
||||
this.props.onRef?.(this);
|
||||
enableNodePath && this.expandLazyLoadNodes();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,12 @@ import {Api} from '../../types';
|
||||
import {isEffectiveApi} from '../../utils/api';
|
||||
import Spinner from '../../components/Spinner';
|
||||
import ResultBox from '../../components/ResultBox';
|
||||
import {autobind, getTreeAncestors, isMobile, createObject} from '../../utils/helper';
|
||||
import {
|
||||
autobind,
|
||||
getTreeAncestors,
|
||||
isMobile,
|
||||
createObject
|
||||
} from '../../utils/helper';
|
||||
import {findDOMNode} from 'react-dom';
|
||||
import {normalizeOptions} from '../../components/Select';
|
||||
import {Action} from '../../types';
|
||||
@ -127,7 +132,7 @@ export default class TreeSelectControl extends React.Component<
|
||||
pathSeparator: '/'
|
||||
};
|
||||
|
||||
treeRef: any
|
||||
treeRef: any;
|
||||
|
||||
container: React.RefObject<HTMLDivElement> = React.createRef();
|
||||
|
||||
@ -417,13 +422,8 @@ export default class TreeSelectControl extends React.Component<
|
||||
|
||||
@autobind
|
||||
handleResultChange(value: Array<Option>) {
|
||||
const {
|
||||
joinValues,
|
||||
extractValue,
|
||||
delimiter,
|
||||
valueField,
|
||||
multiple
|
||||
} = this.props;
|
||||
const {joinValues, extractValue, delimiter, valueField, multiple} =
|
||||
this.props;
|
||||
|
||||
let newValue: any = Array.isArray(value) ? value.concat() : [];
|
||||
|
||||
@ -452,9 +452,12 @@ export default class TreeSelectControl extends React.Component<
|
||||
async resultChangeEvent(value: any) {
|
||||
const {onChange, dispatchEvent, data} = this.props;
|
||||
|
||||
const rendererEvent = await dispatchEvent('change', createObject(data, {
|
||||
value
|
||||
}));
|
||||
const rendererEvent = await dispatchEvent(
|
||||
'change',
|
||||
createObject(data, {
|
||||
value
|
||||
})
|
||||
);
|
||||
|
||||
if (rendererEvent?.prevented) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user