浏览代码

fix: color picker shortcuts not working when elements selected (#3817)

David Luzar 3 年之前
父节点
当前提交
0749d2c1f3
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      src/components/App.tsx

+ 9 - 5
src/components/App.tsx

@@ -1587,17 +1587,21 @@ class App extends React.Component<AppProps, AppState> {
       }
 
       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" });
         }