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: Deleting focused nodes in visual designer resets the current navigation path to the the parent dialog #7018

Merged
merged 6 commits into from
Apr 16, 2021
Merged
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 @@ -132,6 +132,11 @@ export const navigationDispatcher = () => {
const designPageLocation = await snapshot.getPromise(designPageLocationState(skillId ?? projectId));
const { dialogId, selected } = designPageLocation;

const dialogs = await snapshot.getPromise(dialogsSelectorFamily(projectId));
const currentDialog = dialogs.find(({ id }) => id === dialogId);

const encodedSelectPath = encodeArrayPathToDesignerPath(currentDialog?.content, selected);

let currentUri =
skillId == null || skillId === projectId
? `/bot/${projectId}/dialogs/${dialogId}`
Expand All @@ -146,7 +151,7 @@ export const navigationDispatcher = () => {

currentUri = `${currentUri}?selected=${targetSelected}&focused=${encodedFocusPath}`;
} else {
currentUri = `${currentUri}?selected=${selected}`;
currentUri = `${currentUri}?selected=${encodedSelectPath}`;
}

if (fragment && typeof fragment === 'string') {
Expand All @@ -156,7 +161,7 @@ export const navigationDispatcher = () => {

set(designPageLocationState(skillId || projectId), {
dialogId,
selected: getSelected(focusPath) || selected,
selected: getSelected(focusPath) || encodedSelectPath,
focused: focusPath ?? '',
promptTab: Object.values(PromptTab).find((value) => fragment === value),
});
Expand Down