From a604d5cdb8bbfd32f6e78d07bc72177b270ee483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Peters?= Date: Wed, 4 Nov 2026 09:45:17 +0100 Subject: [PATCH] feat: add PrefixProvider for content antd renders outside of Provider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Static antd calls such as notification and Modal.confirm of a different antd copy render their content in a separate React root. Components there lose the mll-ant prefix and get no CSS, since the library ships its styles only under that prefix. Wrapping such content in Provider would prefix it, but its locale mounts the global confirm locale and resets it to English on unmount. PrefixProvider sets only the prefix. 🤖 Generated with Claude Code --- src/Provider/index.test.tsx | 27 ++++++++++++++++++++++++++- src/Provider/index.tsx | 7 +++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Provider/index.test.tsx b/src/Provider/index.test.tsx index 59017bdd..5207eafb 100644 --- a/src/Provider/index.test.tsx +++ b/src/Provider/index.test.tsx @@ -3,8 +3,9 @@ import React from 'react'; import { FilledButton } from '../Button/ColoredButtons'; import { DatePicker } from '../DatePicker'; +import { Modal } from '../Modal'; -import { Provider } from './index'; +import { PrefixProvider, Provider } from './index'; function unprefixedAntdClasses(container: HTMLElement): Array { return Array.from(container.querySelectorAll('[class]')).flatMap((element) => @@ -34,3 +35,27 @@ describe('', () => { expect(screen.getByPlaceholderText('Datum auswählen')).toBeInTheDocument(); }); }); + +describe('', () => { + it('prefixes components', () => { + const { container } = render( + + Speichern + + , + ); + + expect(unprefixedAntdClasses(container)).toEqual([]); + }); + + it('keeps the locale of a surrounding once it unmounts', () => { + render(); + render().unmount(); + + render(); + + expect( + screen.getByRole('button', { name: 'Abbrechen' }), + ).toBeInTheDocument(); + }); +}); diff --git a/src/Provider/index.tsx b/src/Provider/index.tsx index 4f8cae17..d79530e4 100644 --- a/src/Provider/index.tsx +++ b/src/Provider/index.tsx @@ -29,3 +29,10 @@ export function Provider({ ); } + +/** Prefixes content that antd renders outside of , without changing the global locale. */ +export function PrefixProvider({ children }: PropsWithChildren) { + return ( + {children} + ); +}