Skip to content

Commit

Permalink
Merge pull request #24399 from storybookjs/fix-theming-not-updating
Browse files Browse the repository at this point in the history
UI: Fix theming not updating
  • Loading branch information
cdedreuille authored Oct 6, 2023
2 parents b444604 + f6de06b commit 4626d02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 4 additions & 5 deletions code/lib/manager-api/src/modules/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,12 @@ export const init: ModuleFn<SubAPI, SubState> = ({ store, provider, singleStory

const persisted = pick(store.getState(), 'layout', 'selectedPanel');

provider.channel.on(SET_CONFIG, () => {
api.setOptions(merge(api.getInitialOptions(), persisted));
});

return {
api,
state: merge(api.getInitialOptions(), persisted),
init: () => {
provider.channel.on(SET_CONFIG, () => {
api.setOptions(merge(api.getInitialOptions(), persisted));
});
},
};
};
6 changes: 5 additions & 1 deletion code/lib/manager-api/src/tests/layout.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { themes } from '@storybook/theming';
import type { API_Provider } from 'lib/types/src';
import EventEmitter from 'events';
import type { SubAPI, SubState } from '../modules/layout';
import type { SubState as AddonsSubState } from '../modules/addons';
import { defaultLayoutState, init as initLayout } from '../modules/layout';
Expand Down Expand Up @@ -33,7 +34,10 @@ describe('layout API', () => {
return currentState as unknown as State;
}),
} as unknown as Store;
provider = { getConfig: jest.fn(() => ({})) } as unknown as API_Provider<API>;
provider = {
getConfig: jest.fn(() => ({})),
channel: new EventEmitter(),
} as unknown as API_Provider<API>;
layoutApi = initLayout({
store,
provider,
Expand Down

0 comments on commit 4626d02

Please sign in to comment.