bbovenzi commented on code in PR #66251:
URL: https://github.com/apache/airflow/pull/66251#discussion_r3236365740
##########
airflow-core/src/airflow/ui/src/components/DateTimeInput.tsx:
##########
@@ -54,16 +54,31 @@ export const DateTimeInput = forwardRef<HTMLInputElement,
Props>(({ onChange, va
debounceDelay,
);
+ const onPaste = (event: ClipboardEvent<HTMLInputElement>) => {
+ const pasted = event.clipboardData.getData("text");
+ const parsed = dayjs(pasted);
+
+ if (parsed.isValid()) {
+ event.preventDefault();
+ // datetime-local input requires YYYY-MM-DDTHH:mm format
+ const localFormat = parsed.format("YYYY-MM-DDTHH:mm");
+
+ setDisplayDate(localFormat);
+ onDateChange({
+ ...event,
+ target: { ...event.currentTarget, value: localFormat },
+ } as unknown as ChangeEvent<HTMLInputElement>);
+ }
+ };
+
return (
<Input
data-testid="datetime-input"
onChange={(event) => {
- const local = dayjs(event.target.value).isValid() ? event.target.value
: "";
-
- setDisplayDate(local);
- // Parse input to UTC once user finishes typing
Review Comment:
Yes, and thanks for adding in the debounce cancel too
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]