Skip to content

Commit

Permalink
fix: rerender rich text when active locales change [TOL-2606] (#1814)
Browse files Browse the repository at this point in the history
fix: rerender rich text when active locales change
  • Loading branch information
YvesRijckaert authored Dec 4, 2024
1 parent e4a2ea0 commit aec317c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/rich-text/src/SdkProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface SdkProviderProps {
}

function useSdk({ sdk }: SdkProviderProps) {
const sdkMemo = React.useMemo<FieldAppSDK>(() => sdk, []); // eslint-disable-line -- TODO: explain this disable
const sdkMemo = React.useMemo<FieldAppSDK>(() => sdk, [sdk.parameters.instance.activeLocales]); // eslint-disable-line -- TODO: explain this disable

return sdkMemo;
}
Expand Down
11 changes: 8 additions & 3 deletions packages/rich-text/src/Toolbar/_tests_/toolbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const mockSdk = (marks?: MARKS[]): any => {
access: {
can: jest.fn().mockResolvedValue(true),
},
parameters: {
instance: {
activeLocales: [],
},
},
};
};

Expand All @@ -48,7 +53,7 @@ describe('Toolbar', () => {
<Toolbar isDisabled />
</ContentfulEditorIdProvider>
</SdkProvider>
</Plate>,
</Plate>
);
await waitFor(() => {
expect(getByTestId('toolbar-heading-toggle')).toBeDisabled();
Expand Down Expand Up @@ -79,7 +84,7 @@ describe('Toolbar', () => {
<Toolbar isDisabled />
</ContentfulEditorIdProvider>
</SdkProvider>
</Plate>,
</Plate>
);
expect(queryByTestId('dropdown-toolbar-button')).toBeVisible();
});
Expand All @@ -94,7 +99,7 @@ describe('Toolbar', () => {
<Toolbar isDisabled />
</ContentfulEditorIdProvider>
</SdkProvider>
</Plate>,
</Plate>
);
expect(queryByTestId('dropdown-toolbar-button')).not.toBeInTheDocument();
});
Expand Down

0 comments on commit aec317c

Please sign in to comment.