Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: let newly created Action be focused automatically #4667

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
};
}
Expand Down
5 changes: 3 additions & 2 deletions Composer/packages/client/src/shell/useShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/types/src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export type ActionContextApi = {
};

export type DialogEditingContextApi = {
saveData: <T = any>(newData: T, updatePath?: string) => void;
saveData: <T = any>(newData: T, updatePath?: string) => Promise<void>;
onFocusSteps: (stepIds: string[], focusedTab?: string) => void;
onFocusEvent: (eventId: string) => void;
onSelect: (ids: string[]) => void;
Expand Down