From dd52f7568bff0f2125176829ba8b4bd928844d2d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 14 Jun 2020 12:22:54 -0700 Subject: [PATCH] Fix bug preventing a user from being able to "unselect" a word while judging Previously, the selection was accidentally "sticky" unless the player went on to group a word with another. So if the user accidentally clicked a word there was no way to unselect it without maging a bogus grouping and then undoing that. --- empathy/empathy.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index 546df87..973a953 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -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]; - 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; + } + const new_set = new Set([...set].filter(w => w !== word)); this.setState({ selected: null, -- 2.43.0