Skip to content

Commit

Permalink
fix(editor): 修复部分场景下获取不到region的情况 issue#10354
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwenhao committed May 31, 2024
1 parent 1064425 commit b0db2f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/amis-core/src/renderers/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ export function registerOptionsControl(config: OptionsConfig) {
formItem.loadOptionsFromDataScope(
props.source as string,
props.data,
this.changeOptionValue
this.changeOptionValue,
true
);

this.normalizeValue();
Expand Down
14 changes: 13 additions & 1 deletion packages/amis-core/src/store/formItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,12 @@ export const FormItemStore = StoreNode.named('FormItemStore')
function loadOptionsFromDataScope(
source: string,
ctx: Record<string, any>,
onChange?: (value: any) => void
onChange?: (
value: any,
submitOnChange?: boolean,
changeImmediately?: boolean
) => void,
clearValue?: boolean
) {
let options: any[] = resolveVariableAndFilter(source, ctx, '| raw');

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

setOptions(options, onChange, ctx);

// source从数据域获取,同时发生变化时,需要清空当前表单项
if (clearValue && !self.selectFirst) {
self.selectedOptions.some((item: any) => item.__unmatched) &&
onChange &&
onChange('', false, true);
}

return options;
}

Expand Down

0 comments on commit b0db2f7

Please sign in to comment.