Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @fluentui/react-portal-compat: to be compatible with React 18 #27577

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Class ID detection compatible with React 18",
"packageName": "@fluentui/react-portal-compat",
"email": "hanj@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ describe('PortalCompatProvider', () => {
`);
});

it('during register adds a className from "ThemeClassNameContext" context with a React 18 compatible ID', () => {
const element = document.createElement('div');
const { result } = renderHook(() => usePortalCompat(), {
wrapper: props => (
<ThemeClassNameProvider value="fui-FluentProviderR1a">
<PortalCompatProvider>{props.children}</PortalCompatProvider>
</ThemeClassNameProvider>
),
});

expect(result.current(element)).toBeInstanceOf(Function);
expect(element.classList).toMatchInlineSnapshot(`
DOMTokenList {
"0": "fui-FluentProviderR1a",
}
`);
});

it('during unregister remove a className from "ThemeClassNameContext" context', () => {
const element = document.createElement('div');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { applyFocusVisiblePolyfill } from '@fluentui/react-tabster';

import type { RegisterPortalFn } from '@fluentui/react-portal-compat-context';

const CLASS_NAME_REGEX = new RegExp(`(${fluentProviderClassNames.root}\\d+)`);
const CLASS_NAME_REGEX = new RegExp(`(${fluentProviderClassNames.root}\\w+)`);

export const PortalCompatProvider: React.FC<{ children?: React.ReactNode }> = props => {
const { children } = props;
Expand Down