Auto-choose selected item when adding a template

Adding a template by clicking the button without dismissing the lookup
menu first was leaving the menu open and inserting a template with the
query instead of the match.

Changes:
* If the lookup menu is visible, choose the selected item before using
  the value of the lookup input

Depends on I3aa4e87 in OOUI

Bug: 64334
Change-Id: I22e04bd2d3628f03060d3734f9774b811c82f73b
Merge "Auto-choose selected item when adding a template"