Skip to content

Commit

Permalink
fix year issue at the onKeyup at other contexts that not year input.
Browse files Browse the repository at this point in the history
  • Loading branch information
joselrio committed Aug 30, 2024
1 parent 9d41467 commit 338d798
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ function FlatpickrInstance(
*/
function onYearInput(event: KeyboardEvent & IncrementEvent) {
const eventTarget = getEventTarget(event) as HTMLInputElement;

if(eventTarget !== self.yearElements[0]) {
return;
}

const year = parseInt(eventTarget.value) + (event.delta || 0);

if (
Expand Down Expand Up @@ -2488,10 +2493,13 @@ function FlatpickrInstance(
if (t === undefined) return;

const target = t as DayElement;
const newDate = target ? new Date(target.dateObj.getTime()) : self.latestSelectedDateObj as Date;

if(self.latestSelectedDateObj !== newDate) {
self.latestSelectedDateObj = newDate;
}

const selectedDate = (self.latestSelectedDateObj = new Date(
target.dateObj.getTime()
));
const selectedDate = newDate;

const shouldChangeMonth =
(selectedDate.getMonth() < self.currentMonth ||
Expand Down

0 comments on commit 338d798

Please sign in to comment.