-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background is flashing when switching stories #17122
Comments
@shilman I think this transition effect only makes sense when switching backgrounds, not when switching stories. |
Having the same problem... I have a default This is my solution at the moment if it can be useful for someone (just replace // main.js
module.exports = {
/* fix Storybook background flashing, at least for our default color (white) */
previewHead: (head) => `
${head}
<style>
body {
background-color: white !important;
}
</style>
`
} The limitation is that it's just gonna avoid flashing with one colour. If you can choose multiple background colours in your Storybook, then when you switch it, it will go back flashing. But it fixes it for at least one colour, the default one. Before (flashing)Screen.Recording.2022-01-13.at.12.01.27.movAfter (no flashing)Screen.Recording.2022-01-13.at.12.02.32.mov |
@shilman You can also remove "needs triage". |
I found the version which introduced the bug but I'm not sure what's causing it exactly: https://github.com/storybookjs/storybook/releases/tag/v6.4.0-beta.33 @tmeasday @shilman do you think it could be related to the changes for the docs loading state? |
@yannbf I guess it is likely because the "story loading" spinner is ever so briefly appearing. Probably wouldn't be an issue (?) if there wasn't the animation when the background comes back -- is that right? I don't really have good context on the backgrounds addon @yannbf but I wonder if there is some way to do this:
|
Here is a duplicate issue: I have the exact same issue, take a look at my storybook library and switch components to see the bug in action: The repo for the code is here: |
I also found a workaround that flickering issue occurs due to Solution : Turn off transition property for body elementStep 1. Add
Step 3. Start the dev server by disabling cache |
@dsk90it Thanks your workaround works for me! I'll be using this until this gets fixed |
Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.52 containing PR #17753 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Hi @shilman I'm using Storybook V8.0.10 along with storybook-dark-mode v4.0.0. Here's the present scenario: upon initially navigating to a story after clearing the cache, the screen flickers between dark and light modes. However, if I've previously visited that particular story, this flashing behavior doesn't occur. Untitled_.May.9.2024.10_19.PM.webmmain.tsimport type { StorybookConfig } from '@storybook/react-vite';
import { mergeConfig } from 'vite';
const glob = require('glob');
const path = require('path');
const appDirectory = path.resolve(__dirname, '../');
const getStories = () =>
glob.sync(
`${appDirectory}/packages/**/*.@(stories.js|stories.jsx|stories.ts|stories.tsx)`,
{
ignore: `${appDirectory}/packages/**/dist/**/*.@(stories.js|stories.jsx|stories.ts|stories.tsx)`,
}
);
const config: StorybookConfig = {
core: {},
framework: {
name: '@storybook/react-vite',
options: {},
},
stories: getStories(),
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-a11y',
'@storybook/addon-interactions',
'@storybook/addon-coverage',
'storybook-dark-mode',
],
async viteFinal(storybookConfig) {
return mergeConfig(storybookConfig, {
resolve: {
preserveSymlinks: true,
},
server: {
fs: {
allow: ['..'],
},
watch: {
ignored: ['!**/node_modules/@banking-platform/**'],
},
},
assetsInclude: ['**/*.md'],
});
},
docs: {
autodocs: true,
},
};
export default config; preview.jsximport { create } from '@storybook/theming';
import Docs from '../../.storybook/docs';
import { createDarkTheme, createLightTheme } from '../../.storybook/theme';
import '../../.storybook/assets/stories.scss';
import '../../.storybook/assets/style.scss';
import ThemeDecorator from './theme-decorator';
const lightTheme = create({
...createLightTheme,
});
const darkTheme = create({
...createDarkTheme,
});
const customViewports = {
mobile: {
name: 'Mobile',
styles: {
width: '600px',
height: '963px',
},
},
tablet: {
name: 'Tablet',
styles: {
width: '840px',
height: '1194px',
},
},
};
const parameters = {
backgrounds: {
default: 'Surface',
values: [
{
name: 'Background',
value: 'var(--color-background-default)',
},
{
name: 'Surface',
value: 'var(--color-surface-default)',
},
],
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
options: {
storySort: {
order: ['Foundation', 'Actions', 'Inputs'],
},
},
darkMode: {
current: 'light',
dark: darkTheme,
light: lightTheme,
},
docs: {
page: () => <Docs framework="react" />,
},
viewport: { viewports: customViewports },
};
const decorators = [
(Story) => (
<ThemeDecorator>
<Story />
</ThemeDecorator>
),
];
const preview = {
parameters,
decorators,
};
export default preview; |
Describe the bug
When switching stories, the background is flashing which is really annoying.
To Reproduce
https://github.com/Mikilll94/storybook-flash
System
Additional context
This flashing background behavior was not present in Storybook 6.4.0-beta.15. I don't know exactly which Storybook version introduced this annoying behavior.
The text was updated successfully, but these errors were encountered: