patch - to handle caret position on menu resize (needs revision)