Skip to content

Commit 221e17b

Browse files
Unmount dialog & add onOpen (#53307) (#54025)
(cherry picked from commit bb87ad5) Co-authored-by: Wei-Yu Chen <[email protected]>
1 parent 69bb85b commit 221e17b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

airflow-core/src/airflow/ui/src/components/EditableMarkdownButton.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const EditableMarkdownButton = ({
3030
isPending,
3131
mdContent,
3232
onConfirm,
33+
onOpen,
3334
placeholder,
3435
setMdContent,
3536
text,
@@ -40,6 +41,7 @@ const EditableMarkdownButton = ({
4041
readonly isPending: boolean;
4142
readonly mdContent?: string | null;
4243
readonly onConfirm: () => void;
44+
readonly onOpen: () => void;
4345
readonly placeholder: string;
4446
readonly setMdContent: (value: string) => void;
4547
readonly text: string;
@@ -52,7 +54,12 @@ const EditableMarkdownButton = ({
5254
<ActionButton
5355
actionName={placeholder}
5456
icon={icon}
55-
onClick={() => setIsOpen(true)}
57+
onClick={() => {
58+
if (!isOpen) {
59+
onOpen();
60+
}
61+
setIsOpen(true);
62+
}}
5663
text={text}
5764
withText={withText}
5865
/>
@@ -62,6 +69,7 @@ const EditableMarkdownButton = ({
6269
onOpenChange={() => setIsOpen(false)}
6370
open={isOpen}
6471
size="md"
72+
unmountOnExit={true}
6573
>
6674
<Dialog.Content backdrop>
6775
<Dialog.Header bg="blue.muted">

airflow-core/src/airflow/ui/src/pages/Run/Header.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ export const Header = ({
5858
});
5959
}
6060
}, [dagId, dagRun.note, dagRunId, mutate, note]);
61+
62+
const onOpen = () => {
63+
setNote(dagRun.note ?? "");
64+
};
65+
6166
const containerRef = useRef<HTMLDivElement>();
6267
const containerWidth = useContainerWidth(containerRef);
6368

@@ -72,6 +77,7 @@ export const Header = ({
7277
isPending={isPending}
7378
mdContent={note}
7479
onConfirm={onConfirm}
80+
onOpen={onOpen}
7581
placeholder="Add a note..."
7682
setMdContent={setNote}
7783
text={Boolean(dagRun.note) ? "Note" : "Add a note"}

airflow-core/src/airflow/ui/src/pages/TaskInstance/Header.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export const Header = ({
8282
}
8383
}, [dagId, dagRunId, mapIndex, mutate, note, taskId, taskInstance.note]);
8484

85+
const onOpen = () => {
86+
setNote(taskInstance.note ?? "");
87+
};
88+
8589
return (
8690
<Box ref={containerRef}>
8791
<HeaderCard
@@ -93,6 +97,7 @@ export const Header = ({
9397
isPending={isPending}
9498
mdContent={note}
9599
onConfirm={onConfirm}
100+
onOpen={onOpen}
96101
placeholder="Add a note..."
97102
setMdContent={setNote}
98103
text={Boolean(taskInstance.note) ? "Note" : "Add a note"}

0 commit comments

Comments
 (0)