Repository navigation
PM-42839, PM-42840, PM-42841, PM-42842: bug: Minor DatePicker bug fixes - #7343
Conversation
๐ค Bitwarden Claude Code ReviewOverall Assessment: REQUEST CHANGES Reviewed four DatePicker bug fixes: the Code Review Details
|
Codecov Reportโ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7343 +/- ##
=======================================
Coverage 86.07% 86.07%
=======================================
Files 903 903
Lines 66220 66221 +1
Branches 10145 10144 -1
=======================================
+ Hits 57000 57001 +1
Misses 5643 5643
Partials 3577 3577
Flags with carried forward coverage won't be shown. Click here to find out more. โ View full report in Codecov by Harness. ๐ New features to boost your workflow:
|
| val clockTime = clock.instant().atZone(ZoneOffset.UTC) | ||
| val clockDay = clockTime.dayOfYear | ||
| val clockYear = clockTime.year | ||
| val calendarTime = Instant.ofEpochMilli(utcTimeMillis).atZone(ZoneOffset.UTC) | ||
| val calendarDay = calendarTime.dayOfYear | ||
| val calendarYear = calendarTime.year |
There was a problem hiding this comment.
isSelectableYear use the device time zone, so the past/future boundary is off by a day for part of every day.
Details and fix
LocalClock is Clock.systemDefaultZone(), and Material3 highlights "today" using the device zone, but clock.instant().atZone(ZoneOffset.UTC) yields the UTC date.
- Device at UTC+13, 01:00 local on Jan 2: UTC is still Jan 1, so the cell shown as today is treated as future and is disabled for date of birth / issue date (
allowFutureDates = false). - Device at UTC-8, 17:00 local on Jan 1: UTC is already Jan 2, so tomorrow's cell compares equal to "today" and stays selectable โ the exact case this change is meant to block.
isSelectableYear below already uses clock.zone, so the two overrides disagree with each other.
override fun isSelectableDate(utcTimeMillis: Long): Boolean {
val today = LocalDate.now(clock)
val date = Instant.ofEpochMilli(utcTimeMillis).atZone(ZoneOffset.UTC).toLocalDate()
return when {
date.isBefore(today) -> allowPastDates
date.isAfter(today) -> allowFutureDates
else -> allowToday
}
}This also removes the year/dayOfYear branching.
There was a problem hiding this comment.
Claude finished @david-livefront's task in 1m 41s โโ View job
Confirmed โ both findings are resolved
- Gather context (re-read changed files at
5a172af) - Re-check
โ ๏ธ time zone boundary inisSelectableDate - Re-check โป๏ธ missing test coverage for clearing a date
- Post verification result
BitwardenDatePickerDialog.kt:72-78 now derives "today" from LocalDate.now(clock) (device zone, matching isSelectableYear's clock.zone and Material3's own today-highlight) while still reading the incoming utcTimeMillis as UTC โ which is the correct pairing, since Material3 hands you UTC-normalized midnight. The year/dayOfYear branching is gone in favor of isBefore/isAfter, so the UTC+13 and UTC-8 cases from the original comment both behave now.
โป๏ธ Clear-button coverage โ restored. All six clicking the ... clear button should trigger ...Change with null tests in VaultAddEditScreenTest.kt were re-pointed at the new inline icon rather than deleted: each seeds a real date into state, scrolls to the "September 10, 2026. Date of birth" node, and drills to the child with content description "Clear". onDateSelect(null) is covered for License and Passport across date of birth, issue date, and expiration date.
Also verified from the other review threads while I was in the diff: isEnabled is propagated to the clear icon (BitwardenDatePickerButton.kt:91), the "date packer" typo is gone repo-wide, and allowFutureDates now sits before cardStyle at all four call sites.
One small thing still open from my original note, entirely your call: the allowFutureDates = false restriction itself has no direct test โ nothing asserts that a future date is unselectable for date of birth or issue date. The clear-affordance gap, which was the substantive half, is closed.
I did not run the test suite locally; CI on this branch will confirm the re-pointed selectors match.
โข Branch
| AnimateNullableContentVisibility(targetState = currentDate) { | ||
| BitwardenStandardIconButton( | ||
| vectorIconRes = BitwardenDrawable.ic_clear, | ||
| contentDescription = stringResource(id = BitwardenString.clear), | ||
| onClick = { onDateSelect(null) }, | ||
| ) | ||
| } |
There was a problem hiding this comment.
โป๏ธ DEBT: Clearing a date is no longer covered by any test after this change.
Details
VaultAddEditScreenTest drops all six clicking the ... clear button should trigger ...Change with null tests along with the dialog's Clear button, but the replacement affordance (this icon button) has no test, so onDateSelect(null) is now untested for both License and Passport.
Re-pointing those tests at the new clear icon would restore the coverage, and a case for allowFutureDates = false would lock in the new restriction.
There was a problem hiding this comment.
We should check if tests are missing.
There was a problem hiding this comment.
I have added them
| } | ||
| } | ||
|
|
||
| @Suppress("MaxLineLength") |
| * @param actions A lambda containing the set of actions (usually icons or similar) to display | ||
| * in the trailing side. This lambda extends [RowScope], allowing flexibility in defining the | ||
| * layout of the actions. | ||
| * @param allowPastDates Indicates that the date packer allows past dates. |
There was a problem hiding this comment.
Typo "date packer" it also appears a couple of times better to find replace.
| modifier = modifier, | ||
| actions = { | ||
| AnimateNullableContentVisibility(targetState = currentDate) { | ||
| BitwardenStandardIconButton( |
There was a problem hiding this comment.
We should propagate the isEnable to the clear button.
andrebispo5
left a comment
There was a problem hiding this comment.
Some minor quick things. ๐
54490f0 to
5a172af
Compare
|
Thanks @andrebispo5 |

๐๏ธ Tracking
PM-42839
PM-42840
PM-42841
PM-42842
๐ Objective
This PR addresses several small bugs in the DatePicker.
Xbutton to date picker row.๐ธ Screenshots