Browse Source

refine(ui): hide cut/copy context-menu when no text

Andelf 3 years ago
parent
commit
bf0eb9c76b
1 changed files with 10 additions and 8 deletions
  1. 10 8
      src/electron/electron/context_menu.cljs

+ 10 - 8
src/electron/electron/context_menu.cljs

@@ -48,14 +48,16 @@
 
 
             (when editable?
-              (. menu append
-                 (MenuItem. #js {:label "Cut"
-                                 :enabled (and has-text? (.-canCut edit-flags))
-                                 :role "cut"}))
-              (. menu append
-                 (MenuItem. #js {:label "Copy"
-                                 :enabled (.-canCopy edit-flags)
-                                 :role "copy"}))
+              (when has-text?
+                (. menu append
+                   (MenuItem. #js {:label "Cut"
+                                   :enabled (.-canCut edit-flags)
+                                   :role "cut"}))
+                (. menu append
+                   (MenuItem. #js {:label "Copy"
+                                   :enabled (.-canCopy edit-flags)
+                                   :role "copy"})))
+
               (. menu append
                  (MenuItem. #js {:label "Paste"
                                  :enabled (.-canPaste edit-flags)