There are issues where a popover loses the focus of the clicked portal row record already reported. Might this be the case here?
This is just a regular text field, not a portal.
Popovers and Sliders are really just new versions of a tab control. If you select text in a field and then click a tab in a tab control, the focus is also lost so it is not surprising that clicking a popover button moves the focus to the newly opened popover frame--dropping the text selection.
To work around that, you may need to click a regular button that performs a script to:
A) do whatever you need with the selected text. This can include setting variables to the selection start and size for later use in your script.
B) use go to object to open the popover now that the you no longer need to maintain the focus on selected text.