From 272faae52d22700b30cd0b580941473c7c0a740b Mon Sep 17 00:00:00 2001 From: monfera Date: Wed, 27 Feb 2019 10:29:50 +0100 Subject: [PATCH 1/2] Fix: lose element selection on page flip --- .../plugins/canvas/public/state/middleware/aeroelastic.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js b/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js index 9eff1ab885e7f..be2510681975b 100644 --- a/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js +++ b/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js @@ -18,7 +18,7 @@ import { } from '../actions/elements'; import { restoreHistory } from '../actions/history'; import { selectElement } from '../actions/transient'; -import { addPage, removePage, duplicatePage } from '../actions/pages'; +import { addPage, removePage, duplicatePage, gotoPage } from '../actions/pages'; import { appReady } from '../actions/app'; import { setWorkpad } from '../actions/workpad'; import { getNodes, getPages, getSelectedPage, getSelectedElement } from '../selectors/workpad'; @@ -59,6 +59,8 @@ const aeroelasticConfiguration = { const isGroupId = id => id.startsWith(aeroelasticConfiguration.groupName); +const pageChangerActions = [gotoPage.toString(), duplicatePage.toString(), addPage.toString()]; + /** * elementToShape * @@ -320,6 +322,10 @@ export const aeroelastic = ({ dispatch, getState }) => { aero.removeStore(action.payload); } + if (pageChangerActions.indexOf(action.type) >= 0) { + unselectShape(prevPage); + } + next(action); switch (action.type) { From 6ba1b3d9460f4943d18e7dc2b9fe7abc61910bf7 Mon Sep 17 00:00:00 2001 From: monfera Date: Tue, 5 Mar 2019 17:04:48 +0100 Subject: [PATCH 2/2] Fix: remove selection in Redux too (PR feedback from Joe) --- .../plugins/canvas/public/state/middleware/aeroelastic.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js b/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js index be2510681975b..59ae1a9fe382b 100644 --- a/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js +++ b/x-pack/plugins/canvas/public/state/middleware/aeroelastic.js @@ -323,7 +323,11 @@ export const aeroelastic = ({ dispatch, getState }) => { } if (pageChangerActions.indexOf(action.type) >= 0) { - unselectShape(prevPage); + if (getSelectedElement(getState())) { + dispatch(selectElement(null)); // ensure sidebar etc. get updated; will update the layout engine too + } else { + unselectShape(prevPage); // deselect persistent groups as they're not currently selections in Redux + } } next(action);