Skip to content
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

Add date time form field #9133

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add date time form field #9133

wants to merge 2 commits into from

Conversation

Devessier
Copy link
Contributor

@Devessier Devessier commented Dec 18, 2024

  • Create a really simple abstraction to unify the date and date time fields. We might dissociate them sooner than expected.
  • The relative setting is ignored

Copy link

TODOs/FIXMEs:

  • // FIXME: Escape key is not handled properly by the underlying DateInput component. We need to solve that.: packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormDateFieldInput.tsx

Generated by 🚫 dangerJS against 13f00e0

@Devessier Devessier marked this pull request as ready for review December 18, 2024 17:32
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR introduces a new FormDateTimeFieldInput component and refactors date handling by extracting shared functionality into FormDateishFieldInputBase, enabling unified handling of both date and datetime fields.

  • Incomplete Escape key handling in FormDateishFieldInputBase needs fixing (noted in code comment)
  • InternalDatePicker's isDateTimeInput prop is hardcoded to false in FormDateishFieldInputBase, potentially affecting datetime functionality
  • No error state handling for invalid date inputs in FormDateishFieldInputBase
  • Timezone handling in FormDateTimeFieldInput.stories.tsx may need additional test coverage
  • The relative setting is intentionally ignored as noted in PR description, which could affect date display functionality

5 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile

return (
<FormDateishFieldInputBase
mode="datetime"
placeholder="mm/dd/yyyy hh:mm"
Copy link
Contributor

Choose a reason for hiding this comment

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

style: placeholder format 'mm/dd/yyyy hh:mm' doesn't match ISO-8601 format used in defaultValue ('2024-12-09T13:20:19.631Z'). Consider documenting the format conversion or using consistent formats.

) : isFieldDateTime(field) ? (
<FormDateTimeFieldInput
label={field.label}
defaultValue={defaultValue as string | undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: consider handling timezone conversion here since datetime values often need timezone awareness

Comment on lines +18 to +22
<FormDateishFieldInputBase
mode="date"
placeholder="mm/dd/yyyy"
{...{ label, defaultValue, onPersist, VariablePicker }}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Props spreading could hide future prop changes in FormDateishFieldInputBase. Consider explicitly passing each prop.

<OverlayContainer>
<InternalDatePicker
date={pickerDate ?? new Date()}
isDateTimeInput={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: isDateTimeInput is hardcoded to false but mode prop indicates this component handles both date and datetime

persistDate(newDate);
};

const handlePickerEnter = () => {};
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: empty handlePickerEnter function could lead to unexpected behavior when user presses Enter key in picker

Comment on lines +269 to +271
if (!isDefined(parsedInputDateTime)) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: no feedback to user when invalid date is entered

setDraftValue({
type: 'static',
mode: 'edit',
value: newDate?.toDateString() ?? null,
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: using toDateString() loses time information for datetime mode

Comment on lines +72 to +75
await waitFor(() => {
expect(args.onPersist).toHaveBeenCalledWith(
expect.stringMatching(/2024-12-08T\d{2}:10:00.000Z/),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The regex pattern \d{2}:10:00.000Z may be too specific and could fail in different timezones. Consider using a more flexible pattern that accounts for timezone variations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants