jquery/jquery-ui — pull request #1358 by scottgonzalez (2014-10-09 14:30:50+00:00)
Title: Selectmenu: Preserve text selection and button focus on click

Fixes #10639

It's kind of strange that text selection is preserved when interacting with a native select, but we should try to match native behavior as well as possible. I think this is the only way to accomplish this.

It'd be good to have someone else verify this is working properly since I had to try lots of variations of this code to get it working everywhere and it's possible I overlooked something by the end. There are a few scenarios to test:

* Interacting with the button and menu don't throw errors when there is no text selection.
* Clicking the button should always focus the button, any existing text selection should be preserved.
* Click a menu item should focus the button, any existing text selection should be preserved.
* You should always be able to use the arrow keys on an open menu (because focus should be on the button).