-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-8563: Allow anniversary delete and input on enter #1424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Bundle sizes [mpdx-react]Compared against 9aa4279 No significant changes found |
0e9c084
to
489fad2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds keyboard support for anniversary and birthday date fields, allowing users to save or clear dates by pressing Enter. This improves form consistency as other fields already support Enter key interactions.
Key changes:
- Added
handleOnDateEnter
function to process Enter key events on date inputs - Enhanced date fields to handle both saving valid dates and clearing empty inputs on Enter
- Added comprehensive test coverage for the new keyboard functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
PersonShowMore.tsx | Added Enter key handler for anniversary date field |
PersonShowMore.test.tsx | Added comprehensive test suite for anniversary date field interactions |
PersonBirthday.tsx | Added Enter key handler for birthday date field |
PersonBirthday.test.tsx | Added comprehensive test suite for birthday date field interactions |
const handleOnDateEnter = (event: React.KeyboardEvent<HTMLInputElement>) => { | ||
if (event.key === 'Enter') { | ||
const inputValue = (event.target as HTMLInputElement).value.trim(); | ||
if (!inputValue) { | ||
handleDateChange(null); | ||
} else { | ||
const parsed = DateTime.fromFormat(inputValue, 'M/d/yyyy'); | ||
if (parsed.isValid) { | ||
handleDateChange(parsed); | ||
} | ||
} | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is duplicated in both PersonShowMore and PersonBirthday components. Consider extracting it to a shared utility function to follow DRY principles and improve maintainability.
Copilot generated this review using guidance from repository custom instructions.
const handleOnDateEnter = (event: React.KeyboardEvent<HTMLInputElement>) => { | ||
if (event.key === 'Enter') { | ||
const inputValue = (event.target as HTMLInputElement).value.trim(); | ||
if (!inputValue) { | ||
handleDateChange(null); | ||
} else { | ||
const parsed = DateTime.fromFormat(inputValue, 'M/d/yyyy'); | ||
if (parsed.isValid) { | ||
handleDateChange(parsed); | ||
} | ||
} | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is duplicated in both PersonShowMore and PersonBirthday components. Consider extracting it to a shared utility function to follow DRY principles and improve maintainability.
Copilot generated this review using guidance from repository custom instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll probably do this.
@zweatshirt Thanks so much for improving this! The way it worked before is definitely a bad user experience. I have an idea for how to fix this at the source. The root cause seems to be that I'm not saying you need to change it now, but |
Thanks for the detailed response Caleb. I noticed the issue in DesktopDateField but tried to keep the PR in the scope of this Contact Details modal. I'll work on making that change now. |
@zweatshirt Thanks for trying to keep the scope small! We definitely don't want to do more work than we need to. In this case though, I think it is worth solving the root issue. Then your fix will benefit any modal that has date picker inputs. |
Description
Jira ticket
Issue:
Proposed solution:
Other issues/thoughts:
Checklist: