Skip to content

Commit

Permalink
fix(use-calendar-picker): simplified control structure
Browse files Browse the repository at this point in the history
  • Loading branch information
buchananwill committed Oct 3, 2024
1 parent c3f924b commit b96542a
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions packages/components/calendar/src/use-calendar-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,29 +213,20 @@ export function useCalendarPicker(props: CalendarPickerProps) {
if (needsDeferredFocus(e)) {
if (!isKeyDown(e.key)) {
scrollTo(nextValue, list);
} else {
}
} else {
scrollTo(nextValue, list);
}

if (nextItem) {
if (needsDeferredFocus(e)) {
if (!isKeyDown(e.key)) {
if (abortRef.current) {
abortRef.current();
}
handleKeyDown(e.key);
onScrollEnd(list === "months" ? monthsListRef.current : yearsListRef.current, () => {
nextItem.focus();
});
}
} else {
if (abortRef.current) {
abortRef.current();
}
nextItem.focus();
handleKeyDown(e.key);
onScrollEnd(list === "months" ? monthsListRef.current : yearsListRef.current, () => {
nextItem?.focus();
});
}
} else {
scrollTo(nextValue, list);
if (abortRef.current) {
abortRef.current();
}
nextItem?.focus();
}
},
[state, handleKeyDown, isKeyDown],
Expand Down

0 comments on commit b96542a

Please sign in to comment.