Skip to content

Commit

Permalink
fix: 修复单元格中直接放表单项可能取不到值的问题 (baidu#9389)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Jan 11, 2024
1 parent 010f53f commit 636156a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/amis-core/src/renderers/wrapControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,14 @@ export function wrapControl<
} else {
let initialValue = model.extraName
? [
store?.getValueByName(
model.name,
form?.canAccessSuperData
),
store?.getValueByName(
getVariable(data, model.name, form?.canAccessSuperData),
getVariable(
data,
model.extraName,
form?.canAccessSuperData
)
]
: store?.getValueByName(model.name, form?.canAccessSuperData);
: getVariable(data, model.name, form?.canAccessSuperData);

if (
model.extraName &&
Expand Down
33 changes: 33 additions & 0 deletions packages/amis/__tests__/renderers/Form/formitem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,36 @@ test('Renderer:FormItem:disabledInTabs', async () => {
expect(container.querySelector('input[name=a]')).toBeDisabled();
expect(container.querySelector('input[name=b]')).toBeDisabled();
});

test('Renderer:Formitem initial value in table', async () => {
const {container, getByText} = render(
amisRender(
{
type: 'table',
source: '${items}',
columns: [
{
type: 'property',
items: [
{
label: 'A',
content: {
type: 'input-tag',
name: 'a',
static: true
}
}
]
}
]
},
{
data: {
items: [{a: '123'}]
}
},
makeEnv({})
)
);
expect(container.innerHTML).toContain('123');
});

0 comments on commit 636156a

Please sign in to comment.