parkhojeong commented on code in PR #66251:
URL: https://github.com/apache/airflow/pull/66251#discussion_r3226615580


##########
airflow-core/src/airflow/ui/src/components/DateTimeInput.tsx:
##########
@@ -54,16 +54,40 @@ export const DateTimeInput = forwardRef<HTMLInputElement, 
Props>(({ onChange, va
     debounceDelay,
   );
 
+  const onPaste = (event: ClipboardEvent<HTMLInputElement>) => {
+    const pasted = event.clipboardData.getData("text").trim();
+    // Pasted strings with an explicit timezone (e.g. `Z` or `+09:00`) are 
parsed
+    // as their absolute instant. Strings without one are treated as being in 
the
+    // selected Airflow UI timezone — consistent with manual input.
+    const hasExplicitTz = /(?:[Zz]|[+-]\d{2}:?\d{2})$/u.test(pasted);
+    const parsed = hasExplicitTz ? dayjs(pasted) : dayjs.tz(pasted, 
selectedTimezone);
+
+    if (!parsed.isValid()) {
+      return;
+    }
+
+    event.preventDefault();
+    // datetime-local input requires YYYY-MM-DDTHH:mm format in the selected
+    // Airflow UI timezone (not the browser's local timezone).
+    const localFormat = parsed.tz(selectedTimezone).format("YYYY-MM-DDTHH:mm");
+
+    onDateChange({
+      ...event,
+      target: { ...event.currentTarget, value: localFormat },
+    });

Review Comment:
   I think a race condition should be considered because `onDateChange` can be 
called both with and without debounce.
   
   scenario: 
   1. The user manually enters a value, which schedules `debouncedOnDateChange`.
   2. The user pastes a date within the debounce delay.
   3. The paste handler calls `onDateChange` immediately.
    4. The previously scheduled `debouncedOnDateChange` from step 1 runs 
afterward and calls `onDateChange` with the stale manual input value.
     
   As a result, `onDateChange` may use the manual entered value(1) instead of 
the pasted date(2).



-- 
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]

Reply via email to