Skip to content
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": "[email protected]",
"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