From c0a4f7e3357bc11339b10e6636397f4a06eead3c Mon Sep 17 00:00:00 2001 From: ppoffice Date: Sat, 4 Jan 2020 00:54:22 -0500 Subject: [PATCH] fix(widget): no shadow right col if no right col --- layout/common/widgets.jsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/layout/common/widgets.jsx b/layout/common/widgets.jsx index 44e259f..e1160df 100644 --- a/layout/common/widgets.jsx +++ b/layout/common/widgets.jsx @@ -18,16 +18,15 @@ function formatWidgets(widgets) { return result; } +function hasColumn(widgets, position) { + if (Array.isArray(widgets)) { + return typeof widgets.find(widget => widget.position === position) !== 'undefined'; + } + return false; +} + function getColumnCount(widgets) { - let count = 1; - const w = formatWidgets(widgets); - if ('left' in w && w.left.length) { - count++; - } - if ('right' in w && w.right.length) { - count++; - } - return count; + return [hasColumn(widgets, 'left'), hasColumn(widgets, 'right')].filter(v => !!v).length + 1; } function getColumnSizeClass(columnCount) { @@ -88,7 +87,7 @@ class Widgets extends Component { } return null; })} - {position === 'left' ?