Skip to content

[patch] Fix YearMonthPicker focus - #2588

Open
PelayoFelgueroso wants to merge 2 commits into
masterfrom
PelayoFelgueroso/fix-date
Open

PelayoFelgueroso wants to merge 2 commits into
masterfrom
PelayoFelgueroso/fix-date

Conversation

@PelayoFelgueroso

Copy link
Copy Markdown
Collaborator

Checklist
(Check off all the items before submitting)

  • Build process is done without errors. All tests pass in the /lib directory.
  • Self-reviewed the code before submitting.
  • Meets accessibility standards.
  • Added/updated documentation to /website as needed.
  • Added/updated tests as needed.

Purpose
When there is no selectedDate the YearMonthPicker should focus current month and year and keep it visible when opening the YearMonthPicker

export const YearMonthPicker = ({ isYearFirst, selectedDate, today, onYearMonthComplete }: YearMonthPickerProps) => {
const [selectedYear, setSelectedYear] = useState<number | null>(selectedDate?.get("year") || null);
const [selectedMonth, setSelectedMonth] = useState<number | null>(selectedDate?.get("month") || null);
const dateToUse = selectedDate?.isValid() ? selectedDate : today;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of dateToUse I think it's better to call it defaultFocusedDate or something that describes better what is this used for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants