mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-12 11:55:21 +08:00
fix: 修复在 toolbar 中的 form 值变化回显不正确的问题、inputTable当前页数据删除完无法自动调整到上一页问题 (#8328)
* fix: 修复在 toolbar 中的 form 值变化回显不正确的问题 (#8326) * fix: 修复inputTable当前页数据删除完无法自动调整到上一页问题 (#8327) Co-authored-by: wanglinfang <wanglinfang@baidu.com> * fix: 修复 combo 表单项中存在同名表单项时内部表单项值被覆盖的问题 (#8300) --------- Co-authored-by: liaoxuezhi <2betop.cn@gmail.com> Co-authored-by: wanglinfang <wanglinfang@baidu.com>
This commit is contained in:
parent
2146fe97f3
commit
d770d68fbe
@ -245,8 +245,12 @@ export function HocStoreFactory(renderer: {
|
|||||||
...store.data,
|
...store.data,
|
||||||
...props.data
|
...props.data
|
||||||
}
|
}
|
||||||
|
: // combo 不需要同步,如果要同步,在 Combo.tsx 里面已经实现了相关逻辑
|
||||||
|
// 目前主要的问题是,如果 combo 中表单项名字和 combo 本身的名字一样,会导致里面的值会被覆盖成数组
|
||||||
|
props.store?.storeType === 'ComboStore'
|
||||||
|
? undefined
|
||||||
: syncDataFromSuper(
|
: syncDataFromSuper(
|
||||||
props.data,
|
store.data,
|
||||||
(props.data as any).__super,
|
(props.data as any).__super,
|
||||||
(prevProps.data as any).__super,
|
(prevProps.data as any).__super,
|
||||||
store,
|
store,
|
||||||
|
@ -970,3 +970,35 @@ test('Renderer:select autofill in combo', async () => {
|
|||||||
combo: [{type: '1', a: 'a'}]
|
combo: [{type: '1', a: 'a'}]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 10. combo 内部表单项与 combo 同名时,原来会出现内部表单项的值变成数组的情况
|
||||||
|
test('Renderer:combo 内部表单项与 combo 同名', async () => {
|
||||||
|
const {container, submitBtn, findByText, onSubmit, baseElement} = await setup(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
type: 'combo',
|
||||||
|
name: 'a',
|
||||||
|
label: 'combo',
|
||||||
|
className: 'removableFalse',
|
||||||
|
removable: false,
|
||||||
|
multiple: true,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
name: 'a',
|
||||||
|
type: 'input-text',
|
||||||
|
label: 'A'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
value: [{}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
const input = container.querySelector('input[name="a"]') as HTMLInputElement;
|
||||||
|
fireEvent.change(input, {target: {value: '1'}});
|
||||||
|
await wait(400);
|
||||||
|
|
||||||
|
fireEvent.change(input, {target: {value: '123'}});
|
||||||
|
await wait(400);
|
||||||
|
expect(input.value).toBe('123');
|
||||||
|
});
|
||||||
|
@ -1527,11 +1527,14 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
|||||||
|
|
||||||
let items = this.state.items;
|
let items = this.state.items;
|
||||||
let showPager = false;
|
let showPager = false;
|
||||||
const page = this.state.page || 1;
|
let page = this.state.page || 1;
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
let lastPage = 1;
|
let lastPage = 1;
|
||||||
if (typeof perPage === 'number' && perPage && items.length > perPage) {
|
if (typeof perPage === 'number' && perPage && items.length > perPage) {
|
||||||
lastPage = Math.ceil(items.length / perPage);
|
lastPage = Math.ceil(items.length / perPage);
|
||||||
|
if (page > lastPage) {
|
||||||
|
page = lastPage;
|
||||||
|
}
|
||||||
items = items.slice((page - 1) * perPage, page * perPage);
|
items = items.slice((page - 1) * perPage, page * perPage);
|
||||||
showPager = true;
|
showPager = true;
|
||||||
offset = (page - 1) * perPage;
|
offset = (page - 1) * perPage;
|
||||||
@ -1611,7 +1614,8 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
activePage: page,
|
activePage: page,
|
||||||
lastPage: lastPage,
|
perPage,
|
||||||
|
total: this.state.items.length,
|
||||||
onPageChange: this.handlePageChange,
|
onPageChange: this.handlePageChange,
|
||||||
className: 'InputTable-pager'
|
className: 'InputTable-pager'
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,8 @@ export default defineConfig({
|
|||||||
}),
|
}),
|
||||||
monacoEditorPlugin({}),
|
monacoEditorPlugin({}),
|
||||||
replace({
|
replace({
|
||||||
__editor_i18n: !!I18N
|
__editor_i18n: !!I18N,
|
||||||
|
preventAssignment: true
|
||||||
})
|
})
|
||||||
].filter(n => n),
|
].filter(n => n),
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
|
Loading…
Reference in New Issue
Block a user