This is old code, but still wondering: should this not be avatar.markAsFocussed(caretState.isFocused)? Or should this even not be called at all? Yes, should not. Because it puts avatar focus and caretstate.isFocused out of-sync possibly.
So please remove the avatar.markAsFocussed() calls in show() and hide() while touching all this.
Possibly avatar.markAsFocussed should be only called in updateCaret() as well?