Skip to content

Update date picker to allow typing in dates - #101454

Open
Krishna2323 wants to merge 98 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-101117
Open

Krishna2323 wants to merge 98 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue-101117

Conversation

@Krishna2323

@Krishna2323 Krishna2323 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #101117
PROPOSAL:

Tests

Prereqs: Any account. Desktop Chrome and Safari, plus one touch device (mWeb or native).

  1. On desktop, open Settings > Profile > Personal details > Date of birth and click the field.
  2. Verify the calendar opens, the caret is in the year, and the YYYY-MM-DD mask and dashes show in grey.
  3. Type 19900515. Verify focus moves year > month > day on its own and the calendar jumps to May 1990.
  4. Clear the field and type 1990, then 3. Verify the month shows 03 and focus moves to the day.
  5. Press Backspace until the day is empty, then once more. Verify focus moves back to the month.
  6. Use Left/Right arrows and type - or /. Verify focus moves between segments.
  7. Press Cmd/Ctrl+A. Verify the whole date is highlighted. Type 2. Verify the date is replaced starting at the year.
  8. Press Cmd/Ctrl+A, then Backspace. Verify the field empties and focus is in the year.
  9. Paste 2001-02-03 into the year. Verify all three segments fill.
  10. Pick a month and then a year from the calendar header. Verify the field updates and the calendar stays open. Pick a day and verify it closes.
  11. Type 2023-02-31 and tab out. Verify the digits stay and a validation error shows. Tabbing between segments must not show it.
  12. Click the X. Verify the field empties and focus returns to the year.
  13. Type 1990 and 1, then click the empty space right of the date. Verify focus lands in the month.
  14. Open the calendar and scroll the page. Verify the calendar stays attached to the field.
  15. In Safari and Chrome, verify the caret is not clipped after a full year.
  16. With VoiceOver on, verify the segments read as Year, Month, Day with no repeated digits or mask letters.
  17. Save the form and verify the date persists after reload.
  18. On the touch device, tap the field. Verify only the calendar opens and no keyboard appears. Pick a month or year and verify the field value does not change until a day is picked.
  19. Verify there are no JS console errors.
  • Verify that no errors appear in the JS console

Offline tests

  • Same as tests

QA Steps

  • Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web_chrome.mp4

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…calendar on focus

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…gment

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…rolls

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…te field

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@melvin-bot

melvin-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@melvin-bot

melvin-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx bun ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx bun ./scripts/generateTranslations.ts --compare-ref main

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/CONST/index.ts 95.90% <ø> (ø)
...nts/DatePicker/CalendarPicker/MonthPickerModal.tsx 100.00% <100.00%> (ø)
...ents/DatePicker/CalendarPicker/YearPickerModal.tsx 100.00% <100.00%> (ø)
src/components/DatePicker/CalendarPicker/index.tsx 98.37% <100.00%> (+1.73%) ⬆️
src/components/Form/FormContext.tsx 40.00% <100.00%> (+15.00%) ⬆️
src/components/Form/FormProvider.tsx 72.40% <100.00%> (+0.91%) ⬆️
...onents/MoneyRequestConfirmationFields/Provider.tsx 100.00% <ø> (ø)
...mponents/MoneyRequestConfirmationFields/context.ts 80.00% <ø> (ø)
...tConfirmationList/hooks/useConfirmationListData.ts 98.87% <100.00%> (+0.01%) ⬆️
...onfirmationList/hooks/useConfirmationValidation.ts 90.47% <100.00%> (+0.23%) ⬆️
... and 22 more
... and 14 files with indirect coverage changes

@github-actions

Copy link
Copy Markdown
Contributor

🚧 dubielzyk-expensify has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@stephanieelliott
stephanieelliott removed their request for review October 15, 2026 22:19
@marufsharifi

Copy link
Copy Markdown
Contributor

BUG#1: The calendar and date input field are not synchronized.

RF-1

@marufsharifi

Copy link
Copy Markdown
Contributor

BUG#2: When a highlighted date segment try to cut using Cmd+X, its digits are copied to the clipboard, but the selected segment is not cleared from the date field.

RF-2.webm

@marufsharifi

Copy link
Copy Markdown
Contributor

BUG#3: The cursor cannot move between individual digits using the arrow keys, whereas in the latest main branch, it moves between digits one by one.

RF-3.webm

@marufsharifi

Copy link
Copy Markdown
Contributor

It should auto-complete, and it now does.

It doesn't seem to be fixed yet.

RF-4.webm

@marufsharifi

Copy link
Copy Markdown
Contributor

@Krishna2323, could you please take a look at the above bugs reported. thanks.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…the committed date

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

@marufsharifi Fixed two issues and one needs a discussion.

BUG#2 (Cmd+X): Fixed. Cutting a single segment wasn't handled, so the field restored the old value.

BUG#3 (arrow keys): Intentional. Arrows move between segments, like a native date input.

Autocomplete: Fixed. After deleting a digit, the incomplete date wasn't committed. Picking the same date again didn't trigger an update. The calendar now notifies the segments even when the value stays the same.

BUG#1 (calendar/input sync): This also reproduces on main, so I don't think it belongs in this PR. The calendar clamps its view to minDate/maxDate, and the date in the screenshot is outside the allowed range.

heyjennahay
heyjennahay previously approved these changes Oct 19, 2026

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

Product change 👍

@marufsharifi

Copy link
Copy Markdown
Contributor

I've been testing this today. but i will complete my review tomorrow. thanks.

@marufsharifi

Copy link
Copy Markdown
Contributor

@Krishna2323, could you please merge the main. thanks.

@marufsharifi

Copy link
Copy Markdown
Contributor

@marufsharifi Fixed two issues and one needs a discussion.

BUG#2 (Cmd+X): Fixed. Cutting a single segment wasn't handled, so the field restored the old value.

BUG#3 (arrow keys): Intentional. Arrows move between segments, like a native date input.

Autocomplete: Fixed. After deleting a digit, the incomplete date wasn't committed. Picking the same date again didn't trigger an update. The calendar now notifies the segments even when the value stays the same.

BUG#1 (calendar/input sync): This also reproduces on main, so I don't think it belongs in this PR. The calendar clamps its view to minDate/maxDate, and the date in the screenshot is outside the allowed range.

@Krishna2323 based on what you have said here

Since the picker and input should be synchronized, selecting a year should populate the input without triggering a validation error.

This seems to be a regression: #101454

could you please take another look at both issues. thanks.

@marufsharifi

Copy link
Copy Markdown
Contributor

BUG2: When manually entering a Year, for example 1990, typing the first dash (-) moves the focus directly to the day segment instead of advancing to the month segment. As a result, the month field remains empty.

2.mov

This doesn't seems to be fixed yet.

RF-1.webm

@marufsharifi

Copy link
Copy Markdown
Contributor

BUG#1: Pressing Backspace when the month digits are highlighted replace it to 01 instead of clearing the selected month.

RF-2.webm

@marufsharifi

Copy link
Copy Markdown
Contributor

BUG#2: When the user deletes the last digit of the year in the input field and then resizes the browser to a smaller screen size, the year automatically reverts to its previous value.

RF-3.webm

Comment thread src/hooks/useDateSegmentInput.ts
Comment thread src/libs/ValidationUtils.ts
Comment thread src/components/Form/FormProvider.tsx
Comment thread src/components/PopoverProvider/index.tsx
Comment thread src/components/DateSegmentsInput.tsx Outdated
Comment thread src/pages/settings/Wallet/PersonalCardEditTransactionStartDatePage.tsx Outdated
Comment thread src/pages/workspace/companyCards/assignCard/TransactionStartDateStep.tsx Outdated
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…elected segment

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…he Delete key

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The date field refuses to commit an entry it cannot read, so the error reaches the form from
the input rather than from a value the form could validate. That path had no tests: the
confirmation list's dateInvalid branch, the effect that clears the error once the entry reads
as a date again, and FormProvider's merge of input reported errors, including which error
wins when the page has a rule of its own.

The calendar's inbound viewDate catch-up is what makes it follow a date being typed, and the
count that carries each request is what lets the same month be asked for twice. Both are
covered now, along with holding a month or year pick to the dates the calendar offers.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The hook owns focus movement, overwrite on arrival, the undo and redo stacks, copying and
cutting across separate inputs, settling a half typed segment on blur, and the counted
requests that keep the calendar in step. The pure helpers under it were already covered, but
those are the part least likely to regress.

Each segment is given a stand-in for its input, so which segment the caret moved to and what
the browser has selected inside one are both readable without rendering the field.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…r one

The required error, the error the field reports for an entry it could not read, and the two
guards that keep either from being saved were written out in both pages that ask for a
transaction start date. They now ask a hook instead, which is also where they are tested,
rather than the same guard being covered three times over or not at all.

The pages keep their own layout. One is a step in a flow with a loading state and a Next
button, the other a settings page, and the date they mean by starting from the beginning
differs, so a shared component would carry more switches than the duplication costs.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The calendar stays attached to the field while the page scrolls, and a month or year picker
opened from inside it answers escape itself. Both are guards on shared popover code, and a
regression in either would show up as the calendar vanishing mid edit.

An overlay-free popover in a narrow pane is the other half of that, since the calendar has to
sit beside a field in a right hand pane while still becoming a full modal on a small screen.

Jest resolves the native variant of both components, which has none of these listeners, so
the tests ask for the web one by the same route other tests use to ask for the native one.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…date end to end

Each segment is its own input, so the field only counts as left once focus lands outside all
three. The space beside the date holds no text, so a repeated click there stands in for the
word or the line a text field would have selected.

The typing itself is covered through the field rather than through the hook alone: a whole date
reaching the form, a half written one withheld, the digits showing as they are typed, the
calendar opening on the first of them, and a date outside the offered range reporting an error.

Typing is only offered without a touch screen and with room beside the field, so both are mocked
the way the numeric input's tests already mock the first.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

@marufsharifi all the comments/issues are handled, ready for review again.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>

This branch has not been deployed

No deployments
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.

6 participants