Some compositors (e.g., kwin) will send a done event for every commit, regardless of the focus state of the text input. This behavior is arguably(?) out of spec, but otherwise harmless, so just ignore the new state in such cases.
--
To reproduce (without the fix) simple open notepad under kwin and change the focus do a different window. The root cause of this is that kwin is responding to the disable&commit we perform on text_input leave.