Skip to content

PM-42839, PM-42840, PM-42841, PM-42842: bug: Minor DatePicker bug fixes - #7343

Merged
david-livefront merged 1 commit into
mainfrom
PM-42839-PM-42840-PM-42841-PM-42842-date-picker-update
Sep 2, 2026
Merged

david-livefront merged 1 commit into
mainfrom
PM-42839-PM-42840-PM-42841-PM-42842-date-picker-update

Conversation

@david-livefront

@david-livefront david-livefront commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

๐ŸŽŸ๏ธ Tracking

PM-42839
PM-42840
PM-42841
PM-42842

๐Ÿ“” Objective

This PR addresses several small bugs in the DatePicker.

  • Update accessibility announcements.
  • Add X button to date picker row.
  • Disallow selecting future dates for date of birth and issue date.
  • Remove Clear button.

๐Ÿ“ธ Screenshots

Before After

@david-livefront
david-livefront requested a review from a team as a code owner September 1, 2026 20:58
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:bug Change Type - Bug labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

๐Ÿค– Bitwarden Claude Code Review

Overall Assessment: REQUEST CHANGES

Reviewed four DatePicker bug fixes: the "null. " prefix removal in BitwardenTextSelectionButton's content description, the new inline clear icon replacing the dialog's Clear button, the allowPastDates/allowFutureDates/allowToday gating wired into date of birth and issue date, and the dialog button row layout. The content description fix and its test updates are consistent โ€” no stale "null. " assertions remain anywhere in the repo. The date restriction logic has a time zone problem at the past/future boundary, and the deleted clear-button tests were not replaced.

Code Review Details
  • โš ๏ธ : isSelectableDate derives "today" in UTC while the calendar and isSelectableYear use the device zone, making the past/future boundary off by a day for part of every day
    • ui/src/main/kotlin/com/bitwarden/ui/platform/components/dialog/BitwardenDatePickerDialog.kt:72-77
  • โ™ป๏ธ : Clearing a date lost its test coverage โ€” the six deleted clear-button tests have no replacement for the new clear icon, and allowFutureDates = false is untested
    • ui/src/main/kotlin/com/bitwarden/ui/platform/components/dropdown/BitwardenDatePickerButton.kt:86-92

@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

โœ… All modified and coverable lines are covered by tests.
โœ… Project coverage is 86.07%. Comparing base (bcace07) to head (5a172af).
โš ๏ธ Report is 1 commits behind head on main.

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           
Flag Coverage ฮ”
app-data 18.23% <0.00%> (-0.01%) โฌ‡๏ธ
app-ui-auth-tools 18.78% <0.00%> (-0.01%) โฌ‡๏ธ
app-ui-platform 16.31% <0.00%> (-0.01%) โฌ‡๏ธ
app-ui-vault 27.12% <100.00%> (+<0.01%) โฌ†๏ธ
authenticator 6.01% <0.00%> (-0.01%) โฌ‡๏ธ
lib-core-network-bridge 4.04% <0.00%> (-0.01%) โฌ‡๏ธ
lib-data-ui 1.19% <0.00%> (+<0.01%) โฌ†๏ธ

Flags with carried forward coverage won't be shown. Click here to find out more.

โ˜” View full report in Codecov by Harness.
๐Ÿ“ข Have feedback on the report? Share it here.

๐Ÿš€ New features to boost your workflow:
  • โ„๏ธ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ๐Ÿ“ฆ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +72 to +77
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

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.

โš ๏ธ IMPORTANT: "Today" is derived in UTC while the calendar and 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@claude, this has been addressed

@claude claude Bot Sep 2, 2026 •

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.

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 in isSelectableDate
  • Re-check โ™ป๏ธ missing test coverage for clearing a date
  • Post verification result

โš ๏ธ Time zone boundary โ€” fixed. 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

Comment on lines +86 to +92
AnimateNullableContentVisibility(targetState = currentDate) {
BitwardenStandardIconButton(
vectorIconRes = BitwardenDrawable.ic_clear,
contentDescription = stringResource(id = BitwardenString.clear),
onClick = { onDateSelect(null) },
)
}

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.

โ™ป๏ธ 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.

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.

We should check if tests are missing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have added them

}
}

@Suppress("MaxLineLength")

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.

not needed.

* @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.

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.

Typo "date packer" it also appears a couple of times better to find replace.

modifier = modifier,
actions = {
AnimateNullableContentVisibility(targetState = currentDate) {
BitwardenStandardIconButton(

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.

We should propagate the isEnable to the clear button.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call

@andrebispo5 andrebispo5 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.

Some minor quick things. ๐Ÿ‘

@david-livefront
david-livefront force-pushed the PM-42839-PM-42840-PM-42841-PM-42842-date-picker-update branch from 54490f0 to 5a172af Compare September 2, 2026 15:01

@andrebispo5 andrebispo5 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.

Image

@david-livefront

Copy link
Copy Markdown
Collaborator Author

Thanks @andrebispo5

@david-livefront
david-livefront added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit 8a3307c Sep 2, 2026
44 checks passed
@david-livefront
david-livefront deleted the PM-42839-PM-42840-PM-42841-PM-42842-date-picker-update branch September 2, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants