I'm not completely confident that this is the right place to clear this flag. What if the user switches layouts to type a number and then comes back to text input. Won't that have cleared this flag?

I suggest that instead of using this flag, you just test currentInputMode and keyboardName explicitly in needsCandidatePanel(). Its ugly but seems safer. Include a comment explaining the special case hack!

[I put this comment on the new commit rather than here on the PR, so I've copied it here.]