From 32031457d3a97bf75f537db17706f7989d469112 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Wed, 15 Jan 2025 14:13:28 +0000 Subject: [PATCH] Correcting layout of custom component: https://github.com/ioBroker/ioBroker.admin/issues/2886 --- .../src/JsonConfigComponent/ConfigCustom.tsx | 61 ++++++++++--------- .../src/JsonConfigComponent/ConfigGeneric.tsx | 3 +- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/packages/jsonConfig/src/JsonConfigComponent/ConfigCustom.tsx b/packages/jsonConfig/src/JsonConfigComponent/ConfigCustom.tsx index 449ca38ca..24bca34e9 100644 --- a/packages/jsonConfig/src/JsonConfigComponent/ConfigCustom.tsx +++ b/packages/jsonConfig/src/JsonConfigComponent/ConfigCustom.tsx @@ -211,15 +211,32 @@ export default class ConfigCustom extends ConfigGeneric = this.state.Component; + const schema = this.props.schema || ({} as ConfigItemCustom); - // render temporary placeholder - if (!CustomComponent) { - const schema = this.props.schema || ({} as ConfigItemCustom); + let item = CustomComponent ? ( + + ) : this.state.error ? ( +
{this.state.error}
+ ) : ( + + ); - const item = ( + // If any widths are defined + if (schema.xs || schema.sm || schema.md || schema.lg || schema.xl) { + item = ( - {this.state.error ?
{this.state.error}
: } + {item}
); + } - if (schema.newLine) { - return ( - <> -
- {item} - - ); - } - return item; + if (schema.newLine) { + return ( + <> +
+ {item} + + ); } - return ( - - ); + return item; } } diff --git a/packages/jsonConfig/src/JsonConfigComponent/ConfigGeneric.tsx b/packages/jsonConfig/src/JsonConfigComponent/ConfigGeneric.tsx index 503ecc02f..44ff9e6dc 100644 --- a/packages/jsonConfig/src/JsonConfigComponent/ConfigGeneric.tsx +++ b/packages/jsonConfig/src/JsonConfigComponent/ConfigGeneric.tsx @@ -1062,7 +1062,7 @@ export default class ConfigGeneric< const { error, disabled, hidden, defaultValue } = this.calculate(schema); if (hidden) { - // Remove all errors if element is hidden + // Remove all errors if an element is hidden if (Object.keys(this.isError).length) { setTimeout( isError => Object.keys(isError).forEach(attr => this.props.onError(attr)), @@ -1146,7 +1146,6 @@ export default class ConfigGeneric< }} style={{ marginBottom: 0, - // marginRight: 8, textAlign: 'left', width: schema.type === 'divider' || schema.type === 'header' ? schema.width || '100%' : undefined, ...schema.style,