Skip to content

Commit a2fa286

Browse files
Move button listener
1 parent e2c6615 commit a2fa286

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/components/modebar/modebar.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ proto.update = function(graphInfo, buttons) {
4545
this.element.setAttribute('id', modeBarId);
4646
this.element.setAttribute('role', 'toolbar');
4747
this.element.setAttribute('tabindex', '0');
48-
49-
this.element.addEventListener('keydown', function(e) {
50-
if (e.key === 'Enter' || e.key === ' ') {
51-
const activeButton = e.target.closest('.modebar-btn');
52-
if (activeButton) {
53-
activeButton.click();
54-
e.preventDefault();
55-
}
56-
}
57-
});
5848

5949
this._uid = modeBarId;
6050
this.element.className = 'modebar modebar--custom';
@@ -191,6 +181,15 @@ proto.createButton = function(config) {
191181
// only needed for 'hoverClosestGeo' which does not call relayout
192182
_this.updateActiveButton(ev.currentTarget);
193183
});
184+
button.addEventListener('keydown', function(e) {
185+
if (e.key === 'Enter' || e.key === ' ') {
186+
const activeButton = e.target.closest('.modebar-btn');
187+
if (activeButton) {
188+
activeButton.click();
189+
e.preventDefault();
190+
}
191+
}
192+
});
194193
}
195194

196195
button.setAttribute('data-toggle', config.toggle || false);

0 commit comments

Comments
 (0)