 
 (defn hyphenation-ui []
   (let [label "Corrected Hyphenation"
-        valid? (or (string/blank? @hyphenation) (hyphenation-valid? @hyphenation))
-        klass (if valid? "form-group" "form-group has-error")]
+        klass (if (hyphenation-valid? @hyphenation @word) "form-group" "form-group has-error")]
     [:div
      {:class klass}
      [:label {:for "hyphenationInput"} label]


(defn- hyphenation-pattern-edit-ui
  [word new-hyphenation stop save]
  [:tr
   [:td word]
   [:td
    [:input.form-control
     {:type "text"
      :auto-focus true
      :on-change #(reset! new-hyphenation (-> % .-target .-value))
      :on-key-down #(case (.-which %)
                      27 (stop)
                      nil)
      :value @new-hyphenation}]]
   [:td
    [:div.btn-group
     [:button.btn.btn-default
      {:on-click save}
      [:span.glyphicon.glyphicon-ok {:aria-hidden true}] " Save"]
     [:button.btn.btn-default
      {:on-click stop}
      [:span.glyphicon.glyphicon-remove {:aria-hidden true}] " Cancel"]]]])

(defn hyphenation-pattern-item-ui [{:keys [hyphenation] :as pattern}]
  (let [editing (reagent/atom false)

      (let [stop #(do (reset! new-hyphenation hyphenation)
                      (reset! editing false))
            start #(reset! editing true)
            save #(do (when (hyphenation-valid? @new-hyphenation word)
                        (add-hyphenation-pattern! (assoc pattern :hyphenation @new-hyphenation)))
                      (reset! editing false))
            remove #(remove-hyphenation-pattern! pattern)]
