Dashboard: FF dashboardNewLayouts Fix library panels non-editable when multiple added (#107052)
Dashboards: Fix library panels non-editable if multiple were added - dashboardNewLayouts
This commit is contained in:
@@ -139,6 +139,7 @@ describe('AddLibraryPanelWidget', () => {
|
|||||||
expect(behavior.state.uid).toBe('new_uid');
|
expect(behavior.state.uid).toBe('new_uid');
|
||||||
expect(behavior.state.name).toBe('new_name');
|
expect(behavior.state.name).toBe('new_name');
|
||||||
expect(panels[0].state.title).toBe('model title');
|
expect(panels[0].state.title).toBe('model title');
|
||||||
|
expect(panels[0].state.key).toBe('panel-1'); // Key should be preserved from original panel
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set hoverHeader to true if the library panel title is empty', () => {
|
it('should set hoverHeader to true if the library panel title is empty', () => {
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ export class AddLibraryPanelDrawer extends SceneObjectBase<AddLibraryPanelDrawer
|
|||||||
const layoutItem = panelToReplace.parent;
|
const layoutItem = panelToReplace.parent;
|
||||||
|
|
||||||
if (layoutItem && isDashboardLayoutItem(layoutItem)) {
|
if (layoutItem && isDashboardLayoutItem(layoutItem)) {
|
||||||
|
// keep the same key from the panelToReplace
|
||||||
|
// this is important for edit mode
|
||||||
|
newPanel.setState({ key: panelToReplace.state.key });
|
||||||
layoutItem.setElementBody(newPanel);
|
layoutItem.setElementBody(newPanel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user