Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 6696662

Browse files
author
Ian MacLeod
committed
Focus immediately once a context menu pops
1 parent 6ce5af1 commit 6696662

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

paper-focusable.html

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<link href="../polymer/polymer.html" rel="import">
2323

24-
<polymer-element name="paper-focusable" attributes="active focused disabled isToggle" tabindex="0" on-down="{{_downAction}}" on-up="{{_upAction}}" on-focus="{{focusAction}}" on-blur="{{blurAction}}">
24+
<polymer-element name="paper-focusable" attributes="active focused disabled isToggle" tabindex="0" on-down="{{_downAction}}" on-up="{{_upAction}}" on-focus="{{focusAction}}" on-blur="{{blurAction}}" on-contextmenu="{{contextMenuAction}}">
2525

2626
<script>
2727
Polymer('paper-focusable', {
@@ -106,6 +106,21 @@
106106
}
107107
},
108108

109+
// Pulling up the context menu for an item should focus it; but we need to
110+
// be careful about how we deal with down/up events surrounding context
111+
// menus. The up event typically does not fire until the context menu
112+
// closes: so we focus immediately.
113+
//
114+
// This fires _after_ downAction.
115+
contextMenuAction: function(e) {
116+
if (this.disabled) {
117+
return;
118+
}
119+
// Note that upAction may fire _again_ on the actual up event.
120+
this.upAction(e);
121+
this.focusAction();
122+
},
123+
109124
_upAction: function(e) {
110125
if (this.disabled) {
111126
return;

0 commit comments

Comments
 (0)