Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b0db2f7

Browse files
author
chenwenhao
committedMay 31, 2024·
fix(editor): 修复部分场景下获取不到region的情况 issue#10354
1 parent 1064425 commit b0db2f7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
 

‎packages/amis-core/src/renderers/Options.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ export function registerOptionsControl(config: OptionsConfig) {
434434
formItem.loadOptionsFromDataScope(
435435
props.source as string,
436436
props.data,
437-
this.changeOptionValue
437+
this.changeOptionValue,
438+
true
438439
);
439440

440441
this.normalizeValue();

‎packages/amis-core/src/store/formItem.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,12 @@ export const FormItemStore = StoreNode.named('FormItemStore')
866866
function loadOptionsFromDataScope(
867867
source: string,
868868
ctx: Record<string, any>,
869-
onChange?: (value: any) => void
869+
onChange?: (
870+
value: any,
871+
submitOnChange?: boolean,
872+
changeImmediately?: boolean
873+
) => void,
874+
clearValue?: boolean
870875
) {
871876
let options: any[] = resolveVariableAndFilter(source, ctx, '| raw');
872877

@@ -892,6 +897,13 @@ export const FormItemStore = StoreNode.named('FormItemStore')
892897

893898
setOptions(options, onChange, ctx);
894899

900+
// source从数据域获取,同时发生变化时,需要清空当前表单项
901+
if (clearValue && !self.selectFirst) {
902+
self.selectedOptions.some((item: any) => item.__unmatched) &&
903+
onChange &&
904+
onChange('', false, true);
905+
}
906+
895907
return options;
896908
}
897909

0 commit comments

Comments
 (0)
Please sign in to comment.