fix: correctly deselect settings when changing envelope items

This commit is contained in:
David Nguyen
2026-09-26 16:47:27 +10:00
parent 941f4a1e4c
commit c96ee7c84f
@@ -246,6 +246,21 @@ export const EnvelopeEditorFieldsPage = () => {
editorFields.setSelectedRecipient(firstSelectableRecipient?.id ?? null); editorFields.setSelectedRecipient(firstSelectableRecipient?.id ?? null);
}, []); }, []);
/**
* Deselect a field or content which is not on the current envelope item
* when the item changes, otherwise its settings stay open in the sidebar for
* something which is no longer on screen.
*/
useEffect(() => {
if (editorFields.selectedField && editorFields.selectedField.envelopeItemId !== currentEnvelopeItem?.id) {
editorFields.setSelectedField(null);
}
if (editorContents.selectedContent && editorContents.selectedContent.envelopeItemId !== currentEnvelopeItem?.id) {
editorContents.setSelectedContent(null);
}
}, [currentEnvelopeItem?.id]);
const onDetectClick = () => { const onDetectClick = () => {
if (!team.preferences.aiFeaturesEnabled) { if (!team.preferences.aiFeaturesEnabled) {
setIsAiEnableDialogOpen(true); setIsAiEnableDialogOpen(true);