From deb1a8c2fe966680b81c74dc9f098b3f861eb834 Mon Sep 17 00:00:00 2001 From: James Cockshull Date: Wed, 25 Nov 2020 11:35:28 +0700 Subject: [PATCH] Addon-backgrounds: Fix grid offset always using default value - Fix falsy value check to allow zero values in offsetX and offsetY parameters - Fix default value fallback conditional logic --- addons/backgrounds/src/decorators/withGrid.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/backgrounds/src/decorators/withGrid.ts b/addons/backgrounds/src/decorators/withGrid.ts index 0252c57f6a49..e6f4be7a169c 100644 --- a/addons/backgrounds/src/decorators/withGrid.ts +++ b/addons/backgrounds/src/decorators/withGrid.ts @@ -33,8 +33,8 @@ export const withGrid = (StoryFn: StoryFunction, context: StoryContext) => { const isLayoutPadded = parameters.layout === undefined || parameters.layout === 'padded'; // 16px offset in the grid to account for padded layout const defaultOffset = isLayoutPadded ? 16 : 0; - const offsetX = gridParameters.offsetX || isInDocs ? 20 : defaultOffset; - const offsetY = gridParameters.offsetY || isInDocs ? 20 : defaultOffset; + const offsetX = gridParameters.offsetX ?? (isInDocs ? 20 : defaultOffset); + const offsetY = gridParameters.offsetY ?? (isInDocs ? 20 : defaultOffset); const gridStyles = useMemo(() => { const selector =