Skip to content

Commit 80ea1e6

Browse files
authored
chore(react-18-tests-v9): add more issue examples (#34547)
1 parent 90123f7 commit 80ea1e6

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

apps/react-18-tests-v9/src/issues.tsx

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,81 @@
11
/* eslint-disable @typescript-eslint/naming-convention */
22
import * as React from 'react';
33
import { Icon } from '@fluentui/react';
4-
import { Caption1, ComponentProps, Slot } from '@fluentui/react-components';
4+
import type { IContextualMenuProps } from '@fluentui/react';
5+
import { Caption1, ComponentProps, MenuButtonProps, Slot, slot } from '@fluentui/react-components';
56
import type { FluentProviderProps } from '@fluentui/react-provider';
67

8+
// LegacyRef Issue
9+
// using v8 in conjunction with v9 interfaces
10+
{
11+
type AppContextualMenuProps = IContextualMenuProps & {
12+
useLegacyContextMenu?: boolean;
13+
isShadowRendering?: boolean;
14+
isMeasured?: boolean;
15+
contextMenuRef?: React.RefObject<HTMLDivElement | null>;
16+
};
17+
18+
type MenuDefinition = any;
19+
const useGetMenuProps = (menuDefinition?: MenuDefinition) => {
20+
return {} as IContextualMenuProps;
21+
};
22+
23+
type ControlWithMenuProps = {
24+
menuHidden?: boolean;
25+
};
26+
type AppAnchorInternalProps = {};
27+
28+
type AppMenuButtonProps = MenuButtonProps & Omit<AppAnchorInternalProps, 'type'> & ControlWithMenuProps;
29+
30+
type AppMenuButtonSlot = React.FC<Partial<AppMenuButtonProps> & React.RefAttributes<HTMLButtonElement>>;
31+
32+
type ContextualMenuSlotType = React.FC<
33+
Pick<JSX.IntrinsicElements['div'], 'children'> &
34+
(typeof AppContextualMenu extends React.ComponentType<infer Props> ? Props : {})
35+
>;
36+
37+
const AppContextualMenu = React.forwardRef<HTMLDivElement, AppContextualMenuProps>((props, ref) => {
38+
console.log(props, ref);
39+
return <></>;
40+
});
41+
42+
type AppSplitButtonProps = {
43+
menuButton: NonNullable<Slot<AppMenuButtonSlot>>;
44+
menu: NonNullable<Slot<ContextualMenuSlotType>>;
45+
};
46+
47+
const AppSplitButtonMenuButton = React.memo(
48+
React.forwardRef<HTMLButtonElement, AppMenuButtonProps>((props, ref) => {
49+
console.log(props, ref);
50+
return <></>;
51+
}),
52+
);
53+
54+
const props = { menuButton: {}, menu: {} } as AppSplitButtonProps;
55+
56+
const defaultMenuProps = useGetMenuProps();
57+
58+
const appContextualMenuProps: AppContextualMenuProps = {
59+
...defaultMenuProps,
60+
};
61+
62+
const menuButtonDefaultProps: AppMenuButtonProps = {
63+
...defaultMenuProps,
64+
};
65+
66+
slot.always(props.menuButton, {
67+
defaultProps: menuButtonDefaultProps,
68+
elementType: AppSplitButtonMenuButton,
69+
});
70+
71+
slot.always(props.menu, {
72+
defaultProps: appContextualMenuProps,
73+
elementType: AppContextualMenu,
74+
});
75+
}
76+
77+
// children Issue
78+
// using v8/3rd party React components in conjunction with v9
779
{
880
type Slots = {
981
root: NonNullable<Slot<'i'>>;
@@ -19,6 +91,7 @@ import type { FluentProviderProps } from '@fluentui/react-provider';
1991
}
2092
}
2193

94+
// children Issue - non-compatible Component interfaces
2295
{
2396
function Component(props: { textType: React.ComponentType<React.PropsWithChildren<{ className?: string }>> }) {
2497
return <div />;
@@ -29,6 +102,7 @@ import type { FluentProviderProps } from '@fluentui/react-provider';
29102
}
30103
}
31104

105+
// children Issue - non-compatible v9 children type used as react implicit children
32106
{
33107
type Props = Pick<FluentProviderProps, 'children'>;
34108
function Problem(props: Props) {

0 commit comments

Comments
 (0)