Skip to content

Fix todayBorder color being overridden by todayForegroundColor in YearPicker - #189345

Closed
Massinissa-Mouhoub wants to merge 6 commits into
flutter:masterfrom
Massinissa-Mouhoub:issue_189298
Closed

Massinissa-Mouhoub wants to merge 6 commits into
flutter:masterfrom
Massinissa-Mouhoub:issue_189298

Conversation

@Massinissa-Mouhoub

@Massinissa-Mouhoub Massinissa-Mouhoub commented Jul 12, 2026 •

Copy link
Copy Markdown

The current-year item in YearPicker always overrode the color of DatePickerThemeData.todayBorder with the resolved foreground color, so a custom border color set in the theme was ignored. This was already fixed forthe day grid in #177911, but the year selector still had the old behavior.

This PR applies the same color resolution to the year picker as the day picker: the border's own color is used when it is non-transparent, otherwise it falls back to todayForegroundColor.

Before / after with:

DatePickerThemeData(
    todayBorder: BorderSide(color: Colors.red, width: 4),
    todayForegroundColor: WidgetStateProperty.all(Colors.blue),
    todayBackgroundColor: WidgetStateProperty.all(Colors.white),
),
Before After
image image

Added regression tests covering:

  • a custom todayBorder color is respected over the foreground color,
  • the custom border color is kept even when the current year is disabled,
  • a transparent todayBorder color falls back to todayForegroundColor.

Fixes #189298

Please @dkwingsmt review this since it's the same fix as #178792.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Jul 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the _YearPickerState to respect a custom, non-transparent todayBorder color over the foreground color, falling back to the foreground color if the border is transparent. It also adds corresponding regression tests. Feedback on the tests identifies an issue where the currentDate (2016) is set before the firstDate (2018) in a test case, which prevents the year 2016 from being rendered in the YearPicker grid and will cause the test to fail.

Comment thread packages/flutter/test/material/calendar_date_picker_test.dart
@Piinks
Piinks requested a review from QuncCccccc July 15, 2026 21:24
@dkwingsmt
dkwingsmt self-requested a review July 22, 2026 18:14
@QuncCccccc QuncCccccc added the CICD Run CI/CD label Jul 22, 2026

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code change looks good! Thanks a lot for your contribution.

Could you also update the PR description so it can be a bit more accurate. For example, in the sample code, the custom border color seems should be red to match the "After" screenshot. Also "since it's the same fix as #163909." seems the link should be #178792

}

// Regression test for https://github.com/flutter/flutter/issues/189298
testWidgets('Non-null todayBorder color should be respected over foreground color', (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
testWidgets('Non-null todayBorder color should be respected over foreground color', (
testWidgets('Non-null todayBorder color should be respected over todayBackgroundColor', (

borderSide = borderSide.copyWith(color: textColor);
}
final bool hasCustomBorderColor =
datePickerTheme.todayBorder != null && datePickerTheme.todayBorder!.color.opacity != 0.0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe consider to update the doc for datePickerTheme.todayBorder to mention yearpicker as well.

const localizations = DefaultMaterialLocalizations();
final initialDate = DateTime(2016, DateTime.january, 15);
DateTime? selectedDate;
testWidgets('Selected date Semantics announcement on onDateChanged', (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems there are a bunch of reformatting changes. Can we try to rebase master and see if the formatting issues can be fixed?

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 23, 2026
@QuncCccccc QuncCccccc added the CICD Run CI/CD label Jul 23, 2026
- Revert unrelated dart format churn in the Semantics announcement tests
  so the diff only contains the year picker changes.
- Rename the year picker regression test to reflect the todayBackgroundColor
  case.
- Document that DatePickerThemeData.todayBorder also applies to the year
  selector, not just the day grid.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 23, 2026
@Massinissa-Mouhoub

Massinissa-Mouhoub commented Jul 23, 2026 •

Copy link
Copy Markdown
Author

@QuncCccccc I applied your comments please check. I still notice formatting issues, but I don't know if I should keep it like this or revert tbh.

@QuncCccccc

Copy link
Copy Markdown
Contributor

I still notice formatting issues, but I don't know if I should keep it like this or revert tbh.

I think it would be better if we can revert these unrelated changes. Do you need any help? I can push a commit to revert them if that helps.

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Jul 23, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 23, 2026
@Massinissa-Mouhoub

Massinissa-Mouhoub commented Jul 23, 2026 •

Copy link
Copy Markdown
Author

I think it would be better if we can revert these unrelated changes. Do you need any help? I can push a commit to revert them if that helps.

I think I fixed those formatting issues 🤞🤞, @QuncCccccc please check.

@QuncCccccc

Copy link
Copy Markdown
Contributor

Hmm seems I can still see them.
Screenshot 2026-07-23 at 4 04 42 PM

@Massinissa-Mouhoub

Copy link
Copy Markdown
Author

@QuncCccccc what about now ?

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks a lot!

@Massinissa-Mouhoub

Copy link
Copy Markdown
Author

@QuncCccccc, could you please add autosubmit to this PR since it's been approved?

@dkwingsmt dkwingsmt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thank you!

@dkwingsmt dkwingsmt added the CICD Run CI/CD label Jul 27, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 27, 2026
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Aug 5, 2026
@Massinissa-Mouhoub

Copy link
Copy Markdown
Author

@dkwingsmt @QuncCccccc I believe this PR needs waiting for code freeze also since it's been approved ?

@dkwingsmt

Copy link
Copy Markdown
Contributor

Yes it is! I was waiting for a final round of CI check. Here you go.

Thanks for your contribution! This PR has reached completion, however we're not able to merge this PR for the moment due to the Material/Cupertino code freeze (#184093). As soon as the decoupling is complete, we will post a way to port this PR to the new packages to land. In the meantime, I'll convert this PR to a draft and apply a label so that we can quickly find it when the freeze is lifted.

@dkwingsmt
dkwingsmt marked this pull request as draft August 7, 2026 19:32
@dkwingsmt dkwingsmt added the waiting for code freeze This PR is waiting for a code freeze to resolve. label Aug 7, 2026
@Massinissa-Mouhoub

Copy link
Copy Markdown
Author

Since decoupling has finished (congratulations 🎉) I was wondering what is the next step for this PR and this PR.
@dkwingsmt @QuncCccccc

@QuncCccccc

QuncCccccc commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Hi @Massinissa-Mouhoub! Yes! Material_ui and Cupertino_ui start to accept contributions. Guidance and instructions for easily porting over can be found in #188444.

When the port PR is ready, feel free to close this PR:) Thank you!

@Massinissa-Mouhoub

Copy link
Copy Markdown
Author

@QuncCccccc @dkwingsmt This PR has been ported: flutter/packages#12697, please check it.

auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 14, 2026
…roundColor` in `YearPicker` (#12697)

This PR ports flutter/flutter#189345 from flutter/flutter to flutter/packages, as part of flutter/flutter#188444.

Fixes flutter/flutter#189298

## Pre-Review Checklist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages waiting for code freeze This PR is waiting for a code freeze to resolve.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CalendarDatePicker: todayBorder color is still overridden by todayForegroundColor in year picker

3 participants