]> git.cworth.org Git - lmno.games/blobdiff - empathy/empathy.jsx
Fix bug preventing a user from being able to "unselect" a word while judging
[lmno.games] / empathy / empathy.jsx
index 546df87acbbb0129f33deffc8e4996209460800d..973a9537f591e34917ff5a476c997cb795ac3de5 100644 (file)
@@ -436,8 +436,15 @@ class Ambiguities extends React.PureComponent {
       /* Second click on same word removes the word from the group. */
       const idx = this.state.word_sets.findIndex(s => s.has(word));
       const set = this.state.word_sets[idx];
       /* Second click on same word removes the word from the group. */
       const idx = this.state.word_sets.findIndex(s => s.has(word));
       const set = this.state.word_sets[idx];
-      if (set.size === 1)
+      if (set.size === 1) {
+        /* When the word is already alone, there's nothing to do but
+         * to un-select it. */
+        this.setState({
+          selected: null
+        });
         return;
         return;
+      }
+
       const new_set = new Set([...set].filter(w => w !== word));
       this.setState({
         selected: null,
       const new_set = new Set([...set].filter(w => w !== word));
       this.setState({
         selected: null,