From 98c03e918defc20d729bce7ef9a080420ac93ef7 Mon Sep 17 00:00:00 2001 From: Maarten Rijke Date: Fri, 11 Oct 2019 14:12:46 +0200 Subject: [PATCH] fix #8128: addon-centered clashing with addon-docs for react The centered addon was clashing when used in combination with the docs addon. When on the docs page, the centered style should not be applied. Note that this commit only fixes it for React. --- addons/centered/src/react.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/centered/src/react.tsx b/addons/centered/src/react.tsx index f914f3120c7b..a99c60a47e36 100644 --- a/addons/centered/src/react.tsx +++ b/addons/centered/src/react.tsx @@ -5,6 +5,17 @@ import parameters from './parameters'; import styles from './styles'; function centered(storyFn: () => ReactNode) { + /* eslint-disable no-undef */ + if (window) { + const params = new URL(window.location.href).search; + const isInDocsView = params.includes('viewMode=docs'); + + if (isInDocsView) { + return storyFn(); + } + } + /* eslint-enable no-undef */ + return (
{storyFn()}