diff --git a/Composer/packages/adaptive-flow/__tests__/adaptive-flow-editor/stubs/ShellApiStub.ts b/Composer/packages/adaptive-flow/__tests__/adaptive-flow-editor/stubs/ShellApiStub.ts index d2c5583c85..9620c153c1 100644 --- a/Composer/packages/adaptive-flow/__tests__/adaptive-flow-editor/stubs/ShellApiStub.ts +++ b/Composer/packages/adaptive-flow/__tests__/adaptive-flow-editor/stubs/ShellApiStub.ts @@ -10,7 +10,7 @@ const fnPromise = () => Promise.resolve({} as any); export const ShellApiStub: ShellApi = { getDialog: fn, saveDialog: fn, - saveData: fn, + saveData: fnPromise, navTo: fn, onFocusSteps: fn, onFocusEvent: fn, diff --git a/Composer/packages/adaptive-flow/src/adaptive-flow-editor/hooks/useEditorEventApi.ts b/Composer/packages/adaptive-flow/src/adaptive-flow-editor/hooks/useEditorEventApi.ts index 82d35ce423..cb7575dbd9 100644 --- a/Composer/packages/adaptive-flow/src/adaptive-flow-editor/hooks/useEditorEventApi.ts +++ b/Composer/packages/adaptive-flow/src/adaptive-flow-editor/hooks/useEditorEventApi.ts @@ -170,19 +170,20 @@ export const useEditorEventApi = ( if (eventData.$kind === MenuEventTypes.Paste) { handler = (e) => { insertActions(path, data, e.id, e.position, clipboardActions).then((dialog) => { - onChange(dialog); - onFocusSteps([`${e.id}[${e.position || 0}]`]); + return onChange(dialog).then(() => { + onFocusSteps([`${e.id}[${e.position || 0}]`]); + announce(ScreenReaderMessage.ActionCreated); + }); }); - - announce(ScreenReaderMessage.ActionCreated); }; } else { handler = (e) => { const newAction = dialogFactory.create(e.$kind); insertAction(path, data, e.id, e.position, newAction).then((dialog) => { - onChange(dialog); - onFocusSteps([`${e.id}[${e.position || 0}]`]); - announce(ScreenReaderMessage.ActionCreated); + return onChange(dialog).then(() => { + onFocusSteps([`${e.id}[${e.position || 0}]`]); + announce(ScreenReaderMessage.ActionCreated); + }); }); }; } diff --git a/Composer/packages/client/src/shell/useShell.ts b/Composer/packages/client/src/shell/useShell.ts index 82f5a9eba5..2026a0414e 100644 --- a/Composer/packages/client/src/shell/useShell.ts +++ b/Composer/packages/client/src/shell/useShell.ts @@ -193,8 +193,9 @@ export function useShell(source: EventSource, projectId: string): Shell { projectId, }; dialogMapRef.current[dialogId] = updatedDialog; - updateDialog(payload); - commitChanges(); + return updateDialog(payload).then(() => { + commitChanges(); + }); }, updateRegExIntent: updateRegExIntentHandler, renameRegExIntent: renameRegExIntentHandler, diff --git a/Composer/packages/types/src/shell.ts b/Composer/packages/types/src/shell.ts index 6062fbc3ba..5ddd4b8db8 100644 --- a/Composer/packages/types/src/shell.ts +++ b/Composer/packages/types/src/shell.ts @@ -121,7 +121,7 @@ export type ActionContextApi = { }; export type DialogEditingContextApi = { - saveData: (newData: T, updatePath?: string) => void; + saveData: (newData: T, updatePath?: string) => Promise; onFocusSteps: (stepIds: string[], focusedTab?: string) => void; onFocusEvent: (eventId: string) => void; onSelect: (ids: string[]) => void;