Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 6421db6

Browse files
committed
Ensure component renders for modules get overridden
1 parent d093606 commit 6421db6

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/modules/ModuleComponents.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// TODO: @@ Is this future-proof enough? Will we remember to do this for new components?
18+
import { TextInputField } from "@matrix-org/react-sdk-module-api/lib/components/TextInputField";
19+
import { Spinner as ModuleSpinner } from "@matrix-org/react-sdk-module-api/lib/components/Spinner";
20+
import React from "react";
21+
import Field from "../components/views/elements/Field";
22+
import Spinner from "../components/views/elements/Spinner";
23+
24+
TextInputField.renderFactory = (props) => (
25+
<Field
26+
type="text"
27+
value={props.value}
28+
onChange={e => props.onChange(e.target.value)}
29+
label={props.label}
30+
autoComplete="off"
31+
/>
32+
);
33+
ModuleSpinner.renderFactory = () => <Spinner />;

src/modules/ModuleRunner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { TranslationStringsObject } from "@matrix-org/react-sdk-module-api/lib/t
1818
import { AppModule } from "./AppModule";
1919
import { ModuleFactory } from "./ModuleFactory";
2020
import { AnyLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/types";
21+
import "./ModuleComponents";
2122

2223
export class ModuleRunner {
2324
public static readonly instance = new ModuleRunner();

0 commit comments

Comments
 (0)