Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

Commit

Permalink
Fix a bug where clicking on a clickable element ~sometimes~ would clo…
Browse files Browse the repository at this point in the history
…se popovers, etc.
  • Loading branch information
Anton Kovalyov committed Mar 11, 2017
1 parent fd333bd commit 0d2674a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/client/Actions.js
Expand Up @@ -54,6 +54,13 @@ export default class Actions {
while (target && target != root && target != document) {
if (target instanceof HTMLElement) {
let name = target.getAttribute('data-click')

// If the element doesn't have a data-click property but is something
// you'd want to click on (like a text field), return without firing.
if (this.isClickable(target) && !name) {
return
}

if (name) {
this.fire(name, target, ev)
return
Expand All @@ -64,6 +71,18 @@ export default class Actions {
}
}

isClickable(el: HTMLElement) {
switch (el.nodeName) {
case 'BUTTON':
case 'LINK':
case 'INPUT':
case 'TEXTAREA':
return true
}

return false
}

fire(name: string, target: Element, ev: Event) {
if (!this.listeners[name]) {
return
Expand Down

0 comments on commit 0d2674a

Please sign in to comment.