Skip to content

Commit dca6178

Browse files
committed
fix: card one of view layout
1 parent 02635ee commit dca6178

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/lib/kit/components/Inputs/CardOneOf/CardOneOf.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const CardOneOf: ObjectIndependentInput = (props) => {
3939
}
4040

4141
return <Row {...togglerProps} />;
42-
}, [togglerInput, props]);
42+
}, [togglerInput, props, Layout]);
4343

4444
const actions = React.useMemo(() => {
4545
if (isArrayItem(name)) {

src/lib/kit/components/Views/CardOneOfView.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Card, ViewRow} from '../';
66
import {ObjectIndependentView, StringSpec, ViewController} from '../../../core';
77

88
export const CardOneOfView: ObjectIndependentView = (props) => {
9-
const {value = {}, spec, name} = props;
9+
const {value = {}, spec, name, Layout} = props;
1010

1111
const [open, setOpen] = React.useState(true);
1212

@@ -27,14 +27,20 @@ export const CardOneOfView: ObjectIndependentView = (props) => {
2727
);
2828
}, [valueKey, spec.description, specProperties]);
2929

30-
const title = React.useMemo(
31-
() => (
32-
<ViewRow spec={spec as unknown as StringSpec} value={valueName} name={name}>
33-
<>{valueName}</>
34-
</ViewRow>
35-
),
36-
[spec, name, valueName],
37-
);
30+
const title = React.useMemo(() => {
31+
const titleProps = {
32+
spec: spec as unknown as StringSpec,
33+
value: valueName,
34+
name: name,
35+
children: <>{valueName}</>,
36+
} as const;
37+
38+
if (Layout) {
39+
return <Layout {...titleProps} />;
40+
}
41+
42+
return <ViewRow {...titleProps} />;
43+
}, [spec, name, valueName, Layout]);
3844

3945
if (!value || !Object.keys(value).length) {
4046
return null;

0 commit comments

Comments
 (0)