From 0749d2c1f3902ad32f0bdaeefa36bd3b0e137dc7 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Sat, 10 Jul 2021 23:05:00 +0200 Subject: [PATCH] fix: color picker shortcuts not working when elements selected (#3817) --- src/components/App.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index b188aa95..105489da 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1587,17 +1587,21 @@ class App extends React.Component { } if (event.key === KEYS.G || event.key === KEYS.S) { - if (this.state.elementType === "selection") { + const selectedElements = getSelectedElements( + this.scene.getElements(), + this.state, + ); + if ( + this.state.elementType === "selection" && + !selectedElements.length + ) { return; } if ( event.key === KEYS.G && (hasBackground(this.state.elementType) || - getSelectedElements( - this.scene.getElements(), - this.state, - ).some((element) => hasBackground(element.type))) + selectedElements.some((element) => hasBackground(element.type))) ) { this.setState({ openPopup: "backgroundColorPicker" }); }