Skip to content

Commit 78c1f93

Browse files
fix(RTL): add dir="rtl" to html tag when running in RTL (#394)
Closes #366
1 parent 0a57b51 commit 78c1f93

File tree

1 file changed

+7
-2
lines changed
  • packages/main/src/components/ThemeProvider

1 file changed

+7
-2
lines changed

packages/main/src/components/ThemeProvider/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { getCompactSize } from '@ui5/webcomponents-base/dist/config/CompactSize';
22
import { getTheme } from '@ui5/webcomponents-base/dist/config/Theme';
3+
import { getRTL } from '@ui5/webcomponents-base/dist/config/RTL';
34
import { cssVariablesStyles } from '@ui5/webcomponents-react-base/lib/CssSizeVariables';
45
import { ThemingParameters } from '@ui5/webcomponents-react-base/lib/ThemingParameters';
56
import { ContentDensity } from '@ui5/webcomponents-react/lib/ContentDensity';
67
import { MessageToast } from '@ui5/webcomponents-react/lib/MessageToast';
78
import React, { FC, Fragment, ReactNode, useEffect, useMemo } from 'react';
89
import { ThemeProvider as ReactJssThemeProvider } from 'react-jss';
9-
import { JSSTheme } from "../../interfaces/JSSTheme";
10+
import { JSSTheme } from '../../interfaces/JSSTheme';
1011

1112
declare global {
1213
interface Window {
@@ -47,7 +48,8 @@ const ThemeProvider: FC<ThemeProviderProps> = (props: ThemeProviderProps) => {
4748
return {
4849
theme,
4950
contentDensity: isCompactSize ? ContentDensity.Compact : ContentDensity.Cozy,
50-
parameters: ThemingParameters
51+
parameters: ThemingParameters,
52+
rtl: getRTL()
5153
};
5254
}, [theme, isCompactSize]);
5355

@@ -68,6 +70,9 @@ const ThemeProvider: FC<ThemeProviderProps> = (props: ThemeProviderProps) => {
6870
silent: true
6971
});
7072
}
73+
if (getRTL()) {
74+
document.dir = 'rtl';
75+
}
7176
}, []);
7277

7378
return (

0 commit comments

Comments
 (0)