diff --git a/.changeset/sour-monkeys-collect.md b/.changeset/sour-monkeys-collect.md new file mode 100644 index 000000000..13aefe0d8 --- /dev/null +++ b/.changeset/sour-monkeys-collect.md @@ -0,0 +1,5 @@ +--- +'@orchestrator-ui/orchestrator-ui-components': patch +--- + +Fix WfoInlineNoteEdit showing cached value from the previous page on the next one diff --git a/packages/orchestrator-ui-components/src/components/WfoInlineNoteEdit/WfoInlineNoteEdit.tsx b/packages/orchestrator-ui-components/src/components/WfoInlineNoteEdit/WfoInlineNoteEdit.tsx index 86f196103..1b96e9c2b 100644 --- a/packages/orchestrator-ui-components/src/components/WfoInlineNoteEdit/WfoInlineNoteEdit.tsx +++ b/packages/orchestrator-ui-components/src/components/WfoInlineNoteEdit/WfoInlineNoteEdit.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import type { ChangeEvent, FC } from 'react'; import { EuiInlineEditText } from '@elastic/eui'; @@ -20,8 +20,7 @@ export const WfoInlineNoteEdit: FC = ({ onlyShowOnHover = false, }) => { const { theme } = useOrchestratorTheme(); - const initialNote = useMemo(() => value || '', [value]); - const [note, setNote] = useState(initialNote); + const [note, setNote] = useState(value ?? ''); const [isTooltipVisible, setIsTooltipVisible] = useState(true); const [startProcess] = useStartProcessMutation(); @@ -42,15 +41,15 @@ export const WfoInlineNoteEdit: FC = ({ }; const handleCancel = () => { - setNote(initialNote); + setNote(value ?? ''); setIsTooltipVisible(true); }; // This useEffect makes sure the note is updated when a new value property is passed in // for example by a parent component that is update through a websocket event useEffect(() => { - setNote(initialNote); - }, [initialNote]); + setNote(value ?? ''); + }, [value]); return (