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

[map embeddable] fix panel disappears from dashboard when canceling edit after dashboard save #193911

Merged
merged 2 commits into from
Sep 24, 2024
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
53 changes: 25 additions & 28 deletions x-pack/plugins/maps/public/react_embeddable/initialize_edit_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,30 @@ export function initializeEditApi(
parentApi?: unknown,
savedObjectId?: string
) {
if (!parentApi || !apiHasAppContext(parentApi)) {
return {};
}

const parentApiContext = parentApi.getAppContext();

return {
getTypeDisplayName: () => {
return MAP_EMBEDDABLE_NAME;
},
onEdit: async () => {
const stateTransfer = getEmbeddableService().getStateTransfer();
await stateTransfer.navigateToEditor(APP_ID, {
path: getEditPath(savedObjectId),
state: {
embeddableId: uuid,
valueInput: getState(),
originatingApp: parentApiContext.currentAppId,
originatingPath: parentApiContext.getCurrentPath?.(),
return !parentApi || !apiHasAppContext(parentApi)
? {}
: {
getTypeDisplayName: () => {
return MAP_EMBEDDABLE_NAME;
},
onEdit: async () => {
const parentApiContext = parentApi.getAppContext();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix. Call getAppContext inside the scope of onEdit

const stateTransfer = getEmbeddableService().getStateTransfer();
await stateTransfer.navigateToEditor(APP_ID, {
path: getEditPath(savedObjectId),
state: {
embeddableId: uuid,
valueInput: getState(),
originatingApp: parentApiContext.currentAppId,
originatingPath: parentApiContext.getCurrentPath?.(),
},
});
},
isEditingEnabled: () => {
return getMapsCapabilities().save as boolean;
},
getEditHref: async () => {
return getHttp().basePath.prepend(getFullPath(savedObjectId));
},
});
},
isEditingEnabled: () => {
return getMapsCapabilities().save as boolean;
},
getEditHref: async () => {
return getHttp().basePath.prepend(getFullPath(savedObjectId));
},
};
};
}