mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
parent
4f652d8110
commit
7581d7f8ac
1 changed files with 16 additions and 1 deletions
|
@ -6,9 +6,13 @@
|
|||
|
||||
import { duplicatePage } from '../actions/pages';
|
||||
import { fetchRenderable } from '../actions/elements';
|
||||
import { getPages } from '../selectors/workpad';
|
||||
import { setWriteable } from '../actions/workpad';
|
||||
import { getPages, isWriteable } from '../selectors/workpad';
|
||||
import { getWindow } from '../../lib/get_window';
|
||||
|
||||
export const workpadUpdate = ({ dispatch, getState }) => next => action => {
|
||||
const oldIsWriteable = isWriteable(getState());
|
||||
|
||||
next(action);
|
||||
|
||||
// This middleware fetches all of the renderable elements on new, duplicate page
|
||||
|
@ -20,4 +24,15 @@ export const workpadUpdate = ({ dispatch, getState }) => next => action => {
|
|||
// For each element on that page, dispatch the action to update it
|
||||
return newPage.elements.forEach(element => dispatch(fetchRenderable(element)));
|
||||
}
|
||||
|
||||
// This middleware clears any page selection when the writeable mode changes
|
||||
if (action.type === setWriteable.toString() && oldIsWriteable !== isWriteable(getState())) {
|
||||
const win = getWindow();
|
||||
|
||||
if (typeof win.getSelection !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
win.getSelection().collapse(document.querySelector('body'), 0);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue