diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx
index a5a636025..ff5261a2d 100644
--- a/src/lime/_internal/backend/html5/HTML5Window.hx
+++ b/src/lime/_internal/backend/html5/HTML5Window.hx
@@ -1167,6 +1167,10 @@ class HTML5Window
{
if (textInput != null)
{
+ // call blur() before removing the compositionend listener
+ // to ensure that incomplete IME input is committed
+ textInput.blur();
+
textInput.removeEventListener('input', handleInputEvent, true);
textInput.removeEventListener('blur', handleFocusEvent, true);
textInput.removeEventListener('cut', handleCutOrCopyEvent, true);
@@ -1175,7 +1179,6 @@ class HTML5Window
textInput.removeEventListener('compositionstart', handleCompositionstartEvent, true);
textInput.removeEventListener('compositionend', handleCompositionendEvent, true);
- textInput.blur();
}
}