Skip to content

Commit ada511d

Browse files
Merge pull request #257 from open-rpc/fix/content-descriptors-should-overflow-x-scroll
fix: content descriptors pane should overflow-x scroll
2 parents 489950f + 6475daa commit ada511d

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

Diff for: src/ContentDescriptor/ContentDescriptor.test.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ it("renders empty with no schema", () => {
1919
it("renders empty with empty schema", () => {
2020
const div = document.createElement("div");
2121
const emptyContentDescriptor = {} as ContentDescriptorObject;
22-
ReactDOM.render(<ContentDescriptor contentDescriptor={emptyContentDescriptor}/>, div);
22+
ReactDOM.render(<ContentDescriptor contentDescriptor={emptyContentDescriptor} />, div);
2323
expect(div.innerHTML).toBe("");
2424
ReactDOM.unmountComponentAtNode(div);
2525
});
2626

2727
it("renders a name", () => {
2828
const div = document.createElement("div");
29-
ReactDOM.render(<ContentDescriptor contentDescriptor={{name: "foo", schema: {}}}/>, div);
29+
ReactDOM.render(
30+
<ContentDescriptor contentDescriptor={{ name: "foo", schema: {} }} disableTransitionProps={true} />
31+
, div);
3032
expect(div.innerHTML.includes("foo")).toBe(true);
3133
ReactDOM.unmountComponentAtNode(div);
3234
});

Diff for: src/ContentDescriptor/ContentDescriptor.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@ interface IProps extends WithStyles<typeof styles> {
2828
contentDescriptor?: ContentDescriptorObject;
2929
hideIcon?: boolean;
3030
hideRequired?: boolean;
31+
disableTransitionProps?: boolean;
3132
uiSchema?: any;
3233
}
3334

3435
class ContentDescriptor extends Component<IProps> {
3536
public render() {
36-
const { contentDescriptor, classes, hideIcon, hideRequired, uiSchema } = this.props;
37+
const { contentDescriptor, classes, hideIcon, hideRequired, uiSchema, disableTransitionProps } = this.props;
3738
if (!contentDescriptor) { return null; }
3839
const entries = Object.entries(contentDescriptor);
3940
if (entries.length === 0) { return null; }
4041
return (
4142
<ExpansionPanel
4243
style={{ width: "100%" }}
44+
TransitionProps={{unmountOnExit: disableTransitionProps ? false : true}}
4345
defaultExpanded={uiSchema && uiSchema.params["ui:defaultExpanded"]}
4446
expanded={contentDescriptor.name ? undefined : true}>
4547
<ExpansionPanelSummary
@@ -53,8 +55,8 @@ class ContentDescriptor extends Component<IProps> {
5355
</Typography>}
5456
</div>
5557
</ExpansionPanelSummary>
56-
<ExpansionPanelDetails style={{ display: "block" }}>
57-
<div>
58+
<ExpansionPanelDetails style={{ display: "block", overflowX: "auto" }}>
59+
<>
5860
{contentDescriptor.description &&
5961
<ReactMarkdown source={contentDescriptor.description} className={classes.description} />
6062
}
@@ -64,7 +66,7 @@ class ContentDescriptor extends Component<IProps> {
6466
<JSONSchema schema={contentDescriptor.schema} />
6567
</>
6668
}
67-
</div>
69+
</>
6870
</ExpansionPanelDetails>
6971
</ExpansionPanel>
7072
);

Diff for: src/ContentDescriptors/ContentDescriptors.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ it("renders a name", () => {
3535
},
3636
},
3737
} as any;
38-
ReactDOM.render(<ContentDescriptors schema={schema}/>, div);
38+
ReactDOM.render(<ContentDescriptors schema={schema} disableTransitionProps={true}/>, div);
3939
expect(div.innerHTML.includes("foo")).toBe(true);
4040
ReactDOM.unmountComponentAtNode(div);
4141
});

Diff for: src/ContentDescriptors/ContentDescriptors.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { OpenRPC, ContentDescriptorObject } from "@open-rpc/meta-schema";
55

66
interface IProps {
77
schema?: OpenRPC;
8+
disableTransitionProps?: boolean;
89
uiSchema?: any;
910
}
1011

1112
export default class ContentDescriptors extends Component<IProps> {
1213
public render() {
13-
const { schema } = this.props;
14+
const { schema, disableTransitionProps } = this.props;
1415
if (!schema || !schema.components || !schema.components.contentDescriptors) { return null; }
1516
const entries = Object.entries(schema.components.contentDescriptors);
1617
if (entries.length === 0) { return null; }
@@ -21,6 +22,7 @@ export default class ContentDescriptors extends Component<IProps> {
2122
return <ContentDescriptor
2223
key={key}
2324
contentDescriptor={val as ContentDescriptorObject}
25+
disableTransitionProps={disableTransitionProps}
2426
uiSchema={this.props.uiSchema}
2527
hideRequired={true} />;
2628
})}

Diff for: src/Params/Params.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ it("renders params", () => {
3333
},
3434
},
3535
];
36-
ReactDOM.render(<Params params={params}/>, div);
36+
ReactDOM.render(<Params params={params} disableTransitionProps={true}/>, div);
3737
expect(div.innerHTML.includes("tags")).toBe(true);
3838
expect(div.innerHTML.includes("tags to filter by")).toBe(true);
3939
expect(div.innerHTML.includes("string")).toBe(true);

Diff for: src/Params/Params.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const styles = (theme: Theme) => ({
2525

2626
interface IProps extends WithStyles<typeof styles> {
2727
params?: ContentDescriptorObject[];
28+
disableTransitionProps?: boolean;
2829
uiSchema?: any;
2930
}
3031

@@ -46,7 +47,16 @@ class Params extends Component<IProps> {
4647
<TableBody>
4748
<TableRow>
4849
<TableCell colSpan={6}>
49-
{params.map((row) => <ContentDescriptor key={row.name} contentDescriptor={row} uiSchema={uiSchema}/>) }
50+
{
51+
params.map((row) =>
52+
<ContentDescriptor
53+
key={row.name}
54+
contentDescriptor={row}
55+
uiSchema={uiSchema}
56+
disableTransitionProps={this.props.disableTransitionProps}
57+
/>,
58+
)
59+
}
5060
</TableCell>
5161
</TableRow>
5262
</TableBody>

0 commit comments

Comments
 (0)