Skip to content

Conversation

@lucasn4s
Copy link
Collaborator

The DateInput component had a bug where selecting a year and then a month (or vice-versa) would reset the previously selected value. This was due to the handlers relying on the currently selected date string (internalValue) as a base, which didn't reflect intermediate navigation steps.

I fixed this by:

  1. Updating the navigation handlers to use the picker's internal currentDate state as the base.
  2. Using Luxon's .set() method to cleanly update only the relevant part (month or year) while automatically handling day-clamping at month-ends.
  3. Removing premature updates to internalValue during navigation, so the input text only changes when a day is actually picked.

Verification:

  • Added a reproduction test case (manually verified).
  • Ran the full test suite (196 tests passed).
  • Performed frontend verification using Playwright to ensure the calendar view correctly preserves selections.

Fixes #1055


PR created automatically by Jules for task 1088739392285522216 started by @lucasn4s

Modified handleMonthSelection and handleYearSelection to update the
internal currentDate state directly using Luxon's .set() method.
This ensures that when a user selects a new year, the month is preserved,
and when they select a new month, the year is preserved.

Removed redundant side effects that were updating the internalValue
(input selection) during picker navigation, avoiding confusing UI
updates before a day is actually selected.

Updated version to 3.154.2.

Co-authored-by: lucasn4s <17988272+lucasn4s@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@lucasn4s
Copy link
Collaborator Author

Ao abrir tanto a seleção de mês quanto a de ano, é exibido sempre como se apenas o mês de janeiro e o ano de 2026 estivessem selecionados, mesmo que não estejam.

@google-labs-jules
Copy link
Contributor

Ao abrir tanto a seleção de mês quanto a de ano, é exibido sempre como se apenas o mês de janeiro e o ano de 2026 estivessem selecionados, mesmo que não estejam.

Corrigido. Agora os seletores de mês e ano não exibem mais destaques de seleção por padrão (Janeiro/2026) quando nenhuma data está selecionada ou quando a navegação está em andamento. O destaque agora reflete corretamente apenas a data selecionada.

…reset

- Fix reset of year when selecting month (and vice-versa) by using
  currentDate.set() instead of relying on internalValue.
- Fix incorrect highlighting of January/CurrentYear in selection grids
  when no date is selected.
- Updated Vitest snapshots for DateInput.
- Updated project version to 3.154.2.

Co-authored-by: lucasn4s <17988272+lucasn4s@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 Bug Algo não está funcionando

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ano é resetado para o último valor ao selecionar um novo mês, e vice-versa, no DateInput

1 participant