mozilla / translate

Translations website utilizing Bergamot proceedings
https://mozilla.github.io/translate
Mozilla Public License 2.0
59 stars 15 forks source link

ensure output field is cleared when input field is empty #24

Open ansuz opened 2 years ago

ansuz commented 2 years ago

Hi!

This patch addresses #7 in two cases:

  1. When key events on the input field would trigger a call to the worker for the text's translation, if the input is blank (consisting of nothing or whitespace), clear the output field immediately.
  2. Because the worker call is asynchronous, a translation result can be returned and displayed after the output field has already been cleared. In such cases it checks whether the input field is blank, clears the output (as a precaution) and returns before it would normally display the result.