Skip to content

Commit

Permalink
Fix duplicate keydown event firing
Browse files Browse the repository at this point in the history
  • Loading branch information
chmln committed Mar 22, 2019
1 parent e212583 commit 6dd3970
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,6 @@ function FlatpickrInstance(

bind(window.document.body, "keydown", onKeyDown);

if (!self.config.static) bind(self._input, "keydown", onKeyDown);

if (!self.config.inline && !self.config.static)
bind(window, "resize", debouncedResize);

Expand Down Expand Up @@ -1500,7 +1498,9 @@ function FlatpickrInstance(
: self.config.dateFormat
);
return (e.target as HTMLElement).blur();
} else self.open();
} else {
self.open();
}
} else if (
isCalendarElem(e.target as HTMLElement) ||
allowKeydown ||
Expand Down Expand Up @@ -1594,7 +1594,15 @@ function FlatpickrInstance(
e.preventDefault();
(target || self._input).focus();
}
} else if (
!self.config.noCalendar &&
self.daysContainer!.contains(e.target as Node) &&
e.shiftKey
) {
e.preventDefault();
self._input.focus();
}

break;

default:
Expand All @@ -1621,7 +1629,10 @@ function FlatpickrInstance(
break;
}
}
triggerEvent("onKeyDown", e);

if (isInput || isCalendarElem(e.target as HTMLElement)) {
triggerEvent("onKeyDown", e);
}
}

function onMouseOver(elem?: DayElement) {
Expand Down

0 comments on commit 6dd3970

Please sign in to comment.