Skip to content

Commit

Permalink
fix: 修复 quickSaveImmediately 同时配置 api 时上下文信息错误 Close: #8587 (#8588)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop authored Nov 2, 2023
1 parent 8e80dd0 commit b406b42
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/amis-ui/scss/_properties.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ $remFactor: 16px;
/* 此处放置需要override的变量,因为部分变量已经在variables.scss中定义 */
$Table-strip-bg: transparent;

:root,
.AMISCSSWrapper {
:root {
--affix-offset-top: 0px;
--affix-offset-bottom: 0px;
}

:root,
.AMISCSSWrapper {
--white: var(--colors-neutral-text-11);
--primary: var(--colors-brand-5);
--primary-onHover: var(--colors-brand-6);
Expand Down
75 changes: 75 additions & 0 deletions packages/amis/__tests__/renderers/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1243,3 +1243,78 @@ test('Renderer:table-column-quickEdit-inline', async () => {
expect(container.querySelector('.is-checked')).toBeInTheDocument();
});
});

test('Renderer:table-column-quickEdit-saveImmediately', async () => {
const fetcher = jest
.fn()
.mockImplementation(() =>
Promise.resolve({status: 200, data: {status: 0, msg: 'ok'}})
);
const {container, getByText} = render(
amisRender(
{
type: 'table',
title: '表格',
data: {
items: [
{
engine: 'Trident - wixp4',
browser: 'Internet Explorer 4.0',
platform: 'Win 95+',
version: '4',
grade: 'X',
badgeText: '默认',
id: 1
}
]
},
columns: [
{
name: 'engine',
label: 'Engine',
id: 'u:2e5658776790'
},
{
name: 'version',
label: 'Version',
id: 'u:5c41ffc2ecb0',
quickEdit: {
type: 'input-text',
saveImmediately: {
api: '/api/mock2/saveImmediately/${id}'
}
}
}
]
},
{},
makeEnv({
fetcher: fetcher
})
)
);

await wait(200);
const btn = container.querySelector('.cxd-Field-quickEditBtn');
expect(btn).toBeInTheDocument();
fireEvent.click(btn!);
await wait(200);
const input = container.querySelector('input[name=version]');
expect(input).toBeInTheDocument();
fireEvent.change(input!, {target: {value: '5'}});

await wait(200);
expect(getByText('确认')).toBeInTheDocument();
fireEvent.click(getByText('确认'));
await wait(500);
expect(fetcher).toBeCalledTimes(1);
expect(fetcher.mock.calls[0][0].data).toMatchObject({
engine: 'Trident - wixp4',
browser: 'Internet Explorer 4.0',
platform: 'Win 95+',
version: '5',
grade: 'X',
badgeText: '默认',
id: 1
});
});
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export default class Cards extends React.Component<GridProps, object> {
api: saveImmediately.api,
reload: options?.reload
},
values
item.locals
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export default class List extends React.Component<ListProps, object> {
api: saveImmediately.api,
reload: options?.reload
},
values
item.locals
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ export default class Table extends React.Component<TableProps, object> {
api: saveImmediately.api,
reload: options?.reload
},
values
item.locals
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amis/src/renderers/Table2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ export default class Table2 extends React.Component<Table2Props, object> {
api: saveImmediately.api,
reload: options?.reload
},
values
item.locals
);
return;
}
Expand Down

0 comments on commit b406b42

Please sign in to comment.