Skip to content

Commit 8105814

Browse files
Scheduler - Fix incorrect appointment layout on initial Storybook render (#33309)
1 parent 8f03909 commit 8105814

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

apps/react-storybook/.storybook/themes/themes.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const ThemeDecorator: Decorator = (Story, ctx) => {
3838

3939
const [prevTheme, setPrevTheme] = React.useState<string | null>(null);
4040
const [prevCompact, setPrevCompact] = React.useState<boolean | null>(null);
41+
const [cssLoaded, setCssLoaded] = React.useState(false);
4142

4243
React.useEffect(() => {
4344
if (prevTheme !== null && prevCompact !== null) {
@@ -54,9 +55,14 @@ export const ThemeDecorator: Decorator = (Story, ctx) => {
5455
const cssFileHref = `css/dx.${theme}${compact ? '.compact' : ''}.css`;
5556

5657
return (
57-
<div className={`dx-theme-${themeName}-typography storybook-theme-decorator`}>
58-
<link rel="stylesheet" href={cssFileHref} />
59-
<Story />
58+
<div key={cssFileHref} className={`dx-theme-${themeName}-typography storybook-theme-decorator`}>
59+
<link
60+
rel="stylesheet"
61+
href={cssFileHref}
62+
onLoad={() => setCssLoaded(true)}
63+
onError={() => setCssLoaded(true)}
64+
/>
65+
{cssLoaded && <Story />}
6066
</div>
6167
);
6268
}

0 commit comments

Comments
 (0)