* persistData 有可能是 boolean

* 有可能无限 setState

* QuickEdit 默认类型错误

* 恢复 formitem 逻辑
This commit is contained in:
liaoxuezhi 2021-06-21 22:30:43 +08:00 committed by GitHub
parent aa9784482c
commit 216c0a867c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View File

@ -191,9 +191,9 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
const detectData =
schema &&
(schema.detectField === '&' ? rest : rest[schema.detectField || 'data']);
const exprProps = detectData
const exprProps: any = detectData
? getExprProperties(schema, detectData, undefined, rest)
: null;
: {};
if (
exprProps &&
@ -268,7 +268,17 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
const {data: defaultData, value: defaultValue, ...restSchema} = schema;
const Component = renderer.component;
if (rest.invisible && !renderer.isFormItem) {
// 原来表单项的 visible: false 和 hidden: true 表单项的值和验证是有效的
// 而 visibleOn 和 hiddenOn 是无效的,
// 这个本来就是个bug但是已经被广泛使用了
// 我只能继续实现这个bug了
if (
rest.invisible &&
(exprProps.hidden ||
exprProps.visible === false ||
!renderer.isFormItem ||
(schema.visible !== false && !schema.hidden))
) {
return null;
}

View File

@ -159,7 +159,7 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
componentDidUpdate(prevProps: CarouselProps) {
const props = this.props;
const nextOptions = props.options || getPropValue(props);
const nextOptions = props.options || getPropValue(props) || [];
const prevOptions = prevProps.options || getPropValue(prevProps) || [];
if (isArrayChildrenModified(prevOptions, nextOptions)) {

View File

@ -399,7 +399,7 @@ export const HocQuickEdit = (config: Partial<QuickEditConfig> = {}) => (
mode: 'normal',
body: [
{
type: quickEdit.type || 'text',
type: quickEdit.type || 'input-text',
name: quickEdit.name || name,
...quickEdit,
mode: undefined

View File

@ -40,7 +40,7 @@ export const FormStore = ServiceStore.named('FormStore')
savedData: types.frozen(),
// items: types.optional(types.array(types.late(() => FormItemStore)), []),
canAccessSuperData: true,
persistData: '',
persistData: types.optional(types.union(types.string, types.boolean), ''),
restError: types.optional(types.array(types.string), []) // 没有映射到表达项上的 errors
})
.views(self => {