Explicitly specify all children props (#10312)

This commit is contained in:
Michael Telatynski 2023-03-08 13:28:07 +00:00 committed by GitHub
parent ad26925bb6
commit 80fc0997a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 86 additions and 43 deletions

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { ComponentType } from "react"; import React, { ComponentType, PropsWithChildren } from "react";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { _t } from "./languageHandler"; import { _t } from "./languageHandler";
@ -31,7 +31,7 @@ interface IProps {
} }
interface IState { interface IState {
component?: ComponentType; component?: ComponentType<PropsWithChildren<any>>;
error?: Error; error?: Error;
} }

View file

@ -16,7 +16,7 @@ limitations under the License.
*/ */
import classNames from "classnames"; import classNames from "classnames";
import React, { HTMLAttributes, ReactHTML, WheelEvent } from "react"; import React, { HTMLAttributes, ReactHTML, ReactNode, WheelEvent } from "react";
type DynamicHtmlElementProps<T extends keyof JSX.IntrinsicElements> = type DynamicHtmlElementProps<T extends keyof JSX.IntrinsicElements> =
JSX.IntrinsicElements[T] extends HTMLAttributes<{}> ? DynamicElementProps<T> : DynamicElementProps<"div">; JSX.IntrinsicElements[T] extends HTMLAttributes<{}> ? DynamicElementProps<T> : DynamicElementProps<"div">;
@ -30,6 +30,7 @@ export type IProps<T extends keyof JSX.IntrinsicElements> = Omit<DynamicHtmlElem
style?: React.CSSProperties; style?: React.CSSProperties;
tabIndex?: number; tabIndex?: number;
wrappedRef?: (ref: HTMLDivElement) => void; wrappedRef?: (ref: HTMLDivElement) => void;
children: ReactNode;
}; };
export default class AutoHideScrollbar<T extends keyof JSX.IntrinsicElements> extends React.Component<IProps<T>> { export default class AutoHideScrollbar<T extends keyof JSX.IntrinsicElements> extends React.Component<IProps<T>> {

View file

@ -111,7 +111,7 @@ interface IState {
// Generic ContextMenu Portal wrapper // Generic ContextMenu Portal wrapper
// all options inside the menu should be of role=menuitem/menuitemcheckbox/menuitemradiobutton and have tabIndex={-1} // all options inside the menu should be of role=menuitem/menuitemcheckbox/menuitemradiobutton and have tabIndex={-1}
// this will allow the ContextMenu to manage its own focus using arrow keys as per the ARIA guidelines. // this will allow the ContextMenu to manage its own focus using arrow keys as per the ARIA guidelines.
export default class ContextMenu extends React.PureComponent<IProps, IState> { export default class ContextMenu extends React.PureComponent<React.PropsWithChildren<IProps>, IState> {
private readonly initialFocus: HTMLElement; private readonly initialFocus: HTMLElement;
public static defaultProps = { public static defaultProps = {

View file

@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import { NumberSize, Resizable } from "re-resizable"; import { NumberSize, Resizable } from "re-resizable";
import { Direction } from "re-resizable/lib/resizer"; import { Direction } from "re-resizable/lib/resizer";
@ -25,6 +25,7 @@ interface IProps {
resizeNotifier: ResizeNotifier; resizeNotifier: ResizeNotifier;
collapsedRhs?: boolean; collapsedRhs?: boolean;
panel?: JSX.Element; panel?: JSX.Element;
children: ReactNode;
} }
export default class MainSplit extends React.Component<IProps> { export default class MainSplit extends React.Component<IProps> {

View file

@ -74,6 +74,7 @@ interface IProps {
* of the wrapper * of the wrapper
*/ */
fixedChildren?: ReactNode; fixedChildren?: ReactNode;
children?: ReactNode;
/* onFillRequest(backwards): a callback which is called on scroll when /* onFillRequest(backwards): a callback which is called on scroll when
* the user nears the start (backwards = true) or end (backwards = * the user nears the start (backwards = true) or end (backwards =

View file

@ -81,6 +81,7 @@ interface ITileProps {
selected?: boolean; selected?: boolean;
numChildRooms?: number; numChildRooms?: number;
hasPermissions?: boolean; hasPermissions?: boolean;
children?: ReactNode;
onViewRoomClick(): void; onViewRoomClick(): void;
onJoinRoomClick(): Promise<unknown>; onJoinRoomClick(): Promise<unknown>;
onToggleClick?(): void; onToggleClick?(): void;

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { createRef } from "react"; import React, { createRef, ReactNode } from "react";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixClientPeg } from "../../MatrixClientPeg"; import { MatrixClientPeg } from "../../MatrixClientPeg";
@ -54,6 +54,7 @@ import { SDKContext } from "../../contexts/SDKContext";
interface IProps { interface IProps {
isPanelCollapsed: boolean; isPanelCollapsed: boolean;
children?: ReactNode;
} }
type PartialDOMRect = Pick<DOMRect, "width" | "left" | "top" | "height">; type PartialDOMRect = Pick<DOMRect, "width" | "left" | "top" | "height">;

View file

@ -16,11 +16,11 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import AuthFooter from "./AuthFooter"; import AuthFooter from "./AuthFooter";
export default class AuthPage extends React.PureComponent { export default class AuthPage extends React.PureComponent<{ children: ReactNode }> {
public render(): React.ReactNode { public render(): React.ReactNode {
return ( return (
<div className="mx_AuthPage"> <div className="mx_AuthPage">

View file

@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
export default class CompleteSecurityBody extends React.PureComponent { export default class CompleteSecurityBody extends React.PureComponent<{ children: ReactNode }> {
public render(): React.ReactNode { public render(): React.ReactNode {
return <div className="mx_CompleteSecurityBody">{this.props.children}</div>; return <div className="mx_CompleteSecurityBody">{this.props.children}</div>;
} }

View file

@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { useContext } from "react"; import React, { ReactNode, useContext } from "react";
import { RoomMember } from "matrix-js-sdk/src/models/room-member"; import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import { ResizeMethod } from "matrix-js-sdk/src/@types/partials"; import { ResizeMethod } from "matrix-js-sdk/src/@types/partials";
@ -42,6 +42,7 @@ interface IProps extends Omit<React.ComponentProps<typeof BaseAvatar>, "name" |
style?: any; style?: any;
forceHistorical?: boolean; // true to deny `useOnlyCurrentProfiles` usage. Default false. forceHistorical?: boolean; // true to deny `useOnlyCurrentProfiles` usage. Default false.
hideTitle?: boolean; hideTitle?: boolean;
children?: ReactNode;
} }
export default function MemberAvatar({ export default function MemberAvatar({

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import classNames from "classnames"; import classNames from "classnames";
import ContextMenu, { import ContextMenu, {
@ -36,6 +36,7 @@ interface IOptionListProps {
red?: boolean; red?: boolean;
label?: string; label?: string;
className?: string; className?: string;
children: ReactNode;
} }
interface IOptionProps extends React.ComponentProps<typeof MenuItem> { interface IOptionProps extends React.ComponentProps<typeof MenuItem> {
@ -163,7 +164,7 @@ export const IconizedContextMenuOptionList: React.FC<IOptionListProps> = ({
); );
}; };
const IconizedContextMenu: React.FC<IProps> = ({ className, children, compact, ...props }) => { const IconizedContextMenu: React.FC<React.PropsWithChildren<IProps>> = ({ className, children, compact, ...props }) => {
const classes = classNames("mx_IconizedContextMenu", className, { const classes = classNames("mx_IconizedContextMenu", className, {
mx_IconizedContextMenu_compact: compact, mx_IconizedContextMenu_compact: compact,
}); });

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { useContext } from "react"; import React, { ComponentProps, useContext } from "react";
import { MatrixCapabilities } from "matrix-widget-api"; import { MatrixCapabilities } from "matrix-widget-api";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { ApprovalOpts, WidgetLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/WidgetLifecycle"; import { ApprovalOpts, WidgetLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/WidgetLifecycle";
@ -38,7 +38,7 @@ import { getConfigLivestreamUrl, startJitsiAudioLivestream } from "../../../Live
import { ModuleRunner } from "../../../modules/ModuleRunner"; import { ModuleRunner } from "../../../modules/ModuleRunner";
import { ElementWidget } from "../../../stores/widgets/StopGapWidget"; import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
interface IProps extends React.ComponentProps<typeof IconizedContextMenu> { interface IProps extends Omit<ComponentProps<typeof IconizedContextMenu>, "children"> {
app: IApp; app: IApp;
userWidget?: boolean; userWidget?: boolean;
showUnpin?: boolean; showUnpin?: boolean;

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { useState } from "react"; import React, { ReactNode, useState } from "react";
import QuestionDialog from "./QuestionDialog"; import QuestionDialog from "./QuestionDialog";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
@ -30,6 +30,7 @@ interface IProps {
subheading: string; subheading: string;
rageshakeLabel: string; rageshakeLabel: string;
rageshakeData?: Record<string, string>; rageshakeData?: Record<string, string>;
children?: ReactNode;
onFinished(sendFeedback?: boolean): void; onFinished(sendFeedback?: boolean): void;
} }

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { createContext, useState } from "react"; import React, { createContext, ReactNode, useState } from "react";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import classNames from "classnames"; import classNames from "classnames";
@ -29,6 +29,7 @@ export interface IDevtoolsProps {
interface IMinProps extends Pick<IDevtoolsProps, "onBack"> { interface IMinProps extends Pick<IDevtoolsProps, "onBack"> {
className?: string; className?: string;
children?: ReactNode;
} }
interface IProps extends IMinProps { interface IProps extends IMinProps {

View file

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
@ -53,9 +53,10 @@ interface IProps {
primaryDisabled?: boolean; primaryDisabled?: boolean;
// something to stick next to the buttons, optionally // something to stick next to the buttons, optionally
additive?: React.ReactNode; additive?: ReactNode;
primaryButtonClass?: string; primaryButtonClass?: string;
children?: ReactNode;
} }
/** /**

View file

@ -25,6 +25,10 @@ import SdkConfig from "../../../SdkConfig";
import BugReportDialog from "../dialogs/BugReportDialog"; import BugReportDialog from "../dialogs/BugReportDialog";
import AccessibleButton from "./AccessibleButton"; import AccessibleButton from "./AccessibleButton";
interface Props {
children: ReactNode;
}
interface IState { interface IState {
error: Error; error: Error;
} }
@ -33,8 +37,8 @@ interface IState {
* This error boundary component can be used to wrap large content areas and * This error boundary component can be used to wrap large content areas and
* catch exceptions during rendering in the component tree below them. * catch exceptions during rendering in the component tree below them.
*/ */
export default class ErrorBoundary extends React.PureComponent<{}, IState> { export default class ErrorBoundary extends React.PureComponent<Props, IState> {
public constructor(props: {}) { public constructor(props: Props) {
super(props); super(props);
this.state = { this.state = {

View file

@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { Alignment } from "./Tooltip"; import { Alignment } from "./Tooltip";
@ -32,6 +32,7 @@ interface ITooltipProps {
className?: string; className?: string;
tooltipClassName?: string; tooltipClassName?: string;
kind?: InfoTooltipKind; kind?: InfoTooltipKind;
children?: ReactNode;
} }
export default class InfoTooltip extends React.PureComponent<ITooltipProps> { export default class InfoTooltip extends React.PureComponent<ITooltipProps> {

View file

@ -16,7 +16,7 @@ limitations under the License.
import classNames from "classnames"; import classNames from "classnames";
import { EventType } from "matrix-js-sdk/src/@types/event"; import { EventType } from "matrix-js-sdk/src/@types/event";
import React, { useContext, useRef, useState, MouseEvent } from "react"; import React, { useContext, useRef, useState, MouseEvent, ReactNode } from "react";
import MatrixClientContext from "../../../contexts/MatrixClientContext"; import MatrixClientContext from "../../../contexts/MatrixClientContext";
import RoomContext from "../../../contexts/RoomContext"; import RoomContext from "../../../contexts/RoomContext";
@ -35,6 +35,7 @@ interface IProps {
setAvatarUrl(url: string): Promise<unknown>; setAvatarUrl(url: string): Promise<unknown>;
isUserAvatar?: boolean; isUserAvatar?: boolean;
onClick?(ev: MouseEvent<HTMLInputElement>): void; onClick?(ev: MouseEvent<HTMLInputElement>): void;
children?: ReactNode;
} }
const MiniAvatarUploader: React.FC<IProps> = ({ const MiniAvatarUploader: React.FC<IProps> = ({

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { MutableRefObject } from "react"; import React, { MutableRefObject, ReactNode } from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import { isNullOrUndefined } from "matrix-js-sdk/src/utils"; import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
@ -58,6 +58,7 @@ interface IProps {
// Handle to manually notify this PersistedElement that it needs to move // Handle to manually notify this PersistedElement that it needs to move
moveRef?: MutableRefObject<(() => void) | undefined>; moveRef?: MutableRefObject<(() => void) | undefined>;
children: ReactNode;
} }
/** /**

View file

@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
@ -35,6 +35,7 @@ interface IProps {
// A function which will be invoked when an overflow element is required. // A function which will be invoked when an overflow element is required.
// This will be inserted after the children. // This will be inserted after the children.
createOverflowElement?: (overflowCount: number, totalCount: number) => React.ReactNode; createOverflowElement?: (overflowCount: number, totalCount: number) => React.ReactNode;
children?: ReactNode;
} }
export default class TruncatedList extends React.Component<IProps> { export default class TruncatedList extends React.Component<IProps> {

View file

@ -30,6 +30,7 @@ import { Layout } from "../../../settings/enums/Layout";
interface IProps { interface IProps {
mxEvent: MatrixEvent; mxEvent: MatrixEvent;
layout: Layout; layout: Layout;
children: ReactNode;
} }
interface IState { interface IState {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { PollAnswerSubevent } from "matrix-js-sdk/src/extensible_events_v1/PollStartEvent"; import { PollAnswerSubevent } from "matrix-js-sdk/src/extensible_events_v1/PollStartEvent";
@ -47,6 +47,7 @@ interface PollOptionProps extends PollOptionContentProps {
isEnded?: boolean; isEnded?: boolean;
isChecked?: boolean; isChecked?: boolean;
onOptionSelected?: (id: string) => void; onOptionSelected?: (id: string) => void;
children?: ReactNode;
} }
const EndedPollOption: React.FC<Omit<PollOptionProps, "voteCount" | "totalVoteCount">> = ({ const EndedPollOption: React.FC<Omit<PollOptionProps, "voteCount" | "totalVoteCount">> = ({

View file

@ -35,11 +35,13 @@ interface IProps {
onKeyDown?(ev: KeyboardEvent): void; onKeyDown?(ev: KeyboardEvent): void;
cardState?: any; cardState?: any;
ref?: Ref<HTMLDivElement>; ref?: Ref<HTMLDivElement>;
children: ReactNode;
} }
interface IGroupProps { interface IGroupProps {
className?: string; className?: string;
title: string; title: string;
children: ReactNode;
} }
export const Group: React.FC<IGroupProps> = ({ className, title, children }) => { export const Group: React.FC<IGroupProps> = ({ className, title, children }) => {

View file

@ -18,7 +18,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import classNames from "classnames"; import classNames from "classnames";
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
@ -36,6 +36,7 @@ interface IProps {
name: string; name: string;
// Button title // Button title
title: string; title: string;
children?: ReactNode;
} }
// TODO: replace this, the composer buttons and the right panel buttons with a unified representation // TODO: replace this, the composer buttons and the right panel buttons with a unified representation

View file

@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { useCallback, useContext, useEffect, useMemo, useState } from "react"; import React, { ReactNode, useCallback, useContext, useEffect, useMemo, useState } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client"; import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client";
import { RoomMember } from "matrix-js-sdk/src/models/room-member"; import { RoomMember } from "matrix-js-sdk/src/models/room-member";
@ -520,7 +520,9 @@ const warnSelfDemote = async (isSpace: boolean): Promise<boolean> => {
return confirmed; return confirmed;
}; };
const GenericAdminToolsContainer: React.FC<{}> = ({ children }) => { const GenericAdminToolsContainer: React.FC<{
children: ReactNode;
}> = ({ children }) => {
return ( return (
<div className="mx_UserInfo_container"> <div className="mx_UserInfo_container">
<h3>{_t("Admin Tools")}</h3> <h3>{_t("Admin Tools")}</h3>
@ -840,6 +842,7 @@ export const BanToggleButton = ({
interface IBaseRoomProps extends IBaseProps { interface IBaseRoomProps extends IBaseProps {
room: Room; room: Room;
powerLevels: IPowerLevelsContent; powerLevels: IPowerLevelsContent;
children?: ReactNode;
} }
const MuteToggleButton: React.FC<IBaseRoomProps> = ({ member, room, powerLevels, startUpdating, stopUpdating }) => { const MuteToggleButton: React.FC<IBaseRoomProps> = ({ member, room, powerLevels, startUpdating, stopUpdating }) => {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { ReactNode } from "react";
import { lexicographicCompare } from "matrix-js-sdk/src/utils"; import { lexicographicCompare } from "matrix-js-sdk/src/utils";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { throttle } from "lodash"; import { throttle } from "lodash";
@ -36,6 +36,7 @@ interface IProps {
userId: string; userId: string;
showApps: boolean; // Render apps showApps: boolean; // Render apps
resizeNotifier: ResizeNotifier; resizeNotifier: ResizeNotifier;
children?: ReactNode;
} }
interface Counter { interface Counter {

View file

@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { createRef, forwardRef, MouseEvent, RefObject } from "react"; import React, { createRef, forwardRef, MouseEvent, ReactNode, RefObject } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event"; import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event";
import { EventStatus, MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event"; import { EventStatus, MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event";
@ -840,7 +840,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
return false; return false;
} }
private renderContextMenu(): React.ReactFragment { private renderContextMenu(): ReactNode {
if (!this.state.contextMenu) return null; if (!this.state.contextMenu) return null;
const tile = this.getTile(); const tile = this.getTile();
@ -864,7 +864,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
); );
} }
public render(): React.ReactNode { public render(): ReactNode {
const msgtype = this.props.mxEvent.getContent().msgtype; const msgtype = this.props.mxEvent.getContent().msgtype;
const eventType = this.props.mxEvent.getType(); const eventType = this.props.mxEvent.getType();
const { const {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { ComponentProps, createRef } from "react"; import React, { ComponentProps, createRef, ReactNode } from "react";
import { decode } from "html-entities"; import { decode } from "html-entities";
import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { IPreviewUrlResponse } from "matrix-js-sdk/src/client"; import { IPreviewUrlResponse } from "matrix-js-sdk/src/client";
@ -32,6 +32,7 @@ interface IProps {
link: string; link: string;
preview: IPreviewUrlResponse; preview: IPreviewUrlResponse;
mxEvent: MatrixEvent; // the Event associated with the preview mxEvent: MatrixEvent; // the Event associated with the preview
children?: ReactNode;
} }
export default class LinkPreviewWidget extends React.Component<IProps> { export default class LinkPreviewWidget extends React.Component<IProps> {

View file

@ -17,7 +17,7 @@ limitations under the License.
import classNames from "classnames"; import classNames from "classnames";
import { IEventRelation } from "matrix-js-sdk/src/models/event"; import { IEventRelation } from "matrix-js-sdk/src/models/event";
import { M_POLL_START } from "matrix-js-sdk/src/@types/polls"; import { M_POLL_START } from "matrix-js-sdk/src/@types/polls";
import React, { createContext, MouseEventHandler, ReactElement, useContext, useRef } from "react"; import React, { createContext, MouseEventHandler, ReactElement, ReactNode, useContext, useRef } from "react";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixClient } from "matrix-js-sdk/src/client"; import { MatrixClient } from "matrix-js-sdk/src/client";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread"; import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
@ -173,6 +173,7 @@ export const UploadButtonContext = createContext<UploadButtonFn | null>(null);
interface IUploadButtonProps { interface IUploadButtonProps {
roomId: string; roomId: string;
relation?: IEventRelation | null; relation?: IEventRelation | null;
children: ReactNode;
} }
// We put the file input outside the UploadButton component so that it doesn't get killed when the context menu closes. // We put the file input outside the UploadButton component so that it doesn't get killed when the context menu closes.

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { MouseEvent } from "react"; import React, { MouseEvent, ReactNode } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { formatCount } from "../../../../utils/FormattingUtils"; import { formatCount } from "../../../../utils/FormattingUtils";
@ -29,7 +29,7 @@ interface Props {
onClick?: (ev: MouseEvent) => void; onClick?: (ev: MouseEvent) => void;
onMouseOver?: (ev: MouseEvent) => void; onMouseOver?: (ev: MouseEvent) => void;
onMouseLeave?: (ev: MouseEvent) => void; onMouseLeave?: (ev: MouseEvent) => void;
children?: React.ReactChildren | JSX.Element; children?: ReactNode;
label?: string; label?: string;
} }

View file

@ -23,6 +23,7 @@ import React, {
useRef, useRef,
useState, useState,
ChangeEvent, ChangeEvent,
ReactNode,
} from "react"; } from "react";
import classNames from "classnames"; import classNames from "classnames";
import { RoomType } from "matrix-js-sdk/src/@types/event"; import { RoomType } from "matrix-js-sdk/src/@types/event";
@ -158,6 +159,7 @@ interface ISpaceCreateFormProps extends BProps {
nameFieldRef: RefObject<Field>; nameFieldRef: RefObject<Field>;
aliasFieldRef: RefObject<RoomAliasField>; aliasFieldRef: RefObject<RoomAliasField>;
showAliasField?: boolean; showAliasField?: boolean;
children?: ReactNode;
onSubmit(e: SyntheticEvent): void; onSubmit(e: SyntheticEvent): void;
setAlias(alias: string): void; setAlias(alias: string): void;
} }

View file

@ -51,7 +51,9 @@ describe("<ContextMenu />", () => {
onFinished={onFinished} onFinished={onFinished}
chevronFace={ChevronFace.Left} chevronFace={ChevronFace.Left}
chevronOffset={targetChevronOffset} chevronOffset={targetChevronOffset}
/>, >
<React.Fragment />
</ContextMenu>,
); );
const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_left")!; const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_left")!;
@ -78,7 +80,9 @@ describe("<ContextMenu />", () => {
left={targetX} left={targetX}
chevronFace={ChevronFace.Top} chevronFace={ChevronFace.Top}
chevronOffset={targetChevronOffset} chevronOffset={targetChevronOffset}
/>, >
<React.Fragment />
</ContextMenu>,
); );
const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_top")!; const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_top")!;
@ -104,7 +108,9 @@ describe("<ContextMenu />", () => {
onFinished={onFinished} onFinished={onFinished}
chevronFace={ChevronFace.Right} chevronFace={ChevronFace.Right}
chevronOffset={targetChevronOffset} chevronOffset={targetChevronOffset}
/>, >
<React.Fragment />
</ContextMenu>,
); );
const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_right")!; const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_right")!;
@ -130,7 +136,9 @@ describe("<ContextMenu />", () => {
chevronFace={ChevronFace.Bottom} chevronFace={ChevronFace.Bottom}
onFinished={onFinished} onFinished={onFinished}
chevronOffset={targetChevronOffset} chevronOffset={targetChevronOffset}
/>, >
<React.Fragment />
</ContextMenu>,
); );
const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_bottom")!; const chevron = document.querySelector<HTMLElement>(".mx_ContextualMenu_chevron_bottom")!;
@ -157,7 +165,9 @@ describe("<ContextMenu />", () => {
chevronFace={ChevronFace.Bottom} chevronFace={ChevronFace.Bottom}
onFinished={onFinished} onFinished={onFinished}
chevronOffset={targetChevronOffset} chevronOffset={targetChevronOffset}
/>, >
<React.Fragment />
</ContextMenu>,
); );
expect(onFinished).not.toHaveBeenCalled(); expect(onFinished).not.toHaveBeenCalled();
@ -177,7 +187,9 @@ describe("<ContextMenu />", () => {
chevronFace={ChevronFace.Bottom} chevronFace={ChevronFace.Bottom}
onFinished={onFinished} onFinished={onFinished}
chevronOffset={targetChevronOffset} chevronOffset={targetChevronOffset}
/>, >
<React.Fragment />
</ContextMenu>,
); );
expect(onFinished).not.toHaveBeenCalled(); expect(onFinished).not.toHaveBeenCalled();