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

[Canvas] Fix: lose element selection on page flip #32111

Merged
merged 2 commits into from
Mar 8, 2019

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Feb 27, 2019

Fixes #31839 - thanks Joe for the report

deselect

@monfera monfera added review v7.0.0 Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v6.7.0 v7.2.0 v6.7.1 v7.0.1 labels Feb 27, 2019
@monfera monfera self-assigned this Feb 27, 2019
@monfera monfera requested a review from a team as a code owner February 27, 2019 09:52
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-canvas

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cqliu1 cqliu1 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@w33ble w33ble left a comment

Choose a reason for hiding this comment

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

The sidebar is still out of sync with the element selection, but now it's inverted. Previously the element would be selected by the sidebar was for the workpad, not the element. Now, nothing is selected, but the sidebar is still for the element that used to be selected.

feb-28-2019 12-57-26

@monfera
Copy link
Contributor Author

monfera commented Mar 5, 2019

Thanks @w33ble, looking into it

@monfera monfera force-pushed the lose-selection-on-page-flip branch from f91b840 to 6ba1b3d Compare March 5, 2019 17:13
@elasticmachine
Copy link
Contributor

💔 Build Failed

@monfera
Copy link
Contributor Author

monfera commented Mar 5, 2019

retest

@monfera monfera requested a review from w33ble March 5, 2019 19:21
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@w33ble w33ble left a comment

Choose a reason for hiding this comment

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

Functionality looks good. Code looks good, except for the one part I pointed out.

@@ -320,6 +322,14 @@ export const aeroelastic = ({ dispatch, getState }) => {
aero.removeStore(action.payload);
}

if (pageChangerActions.indexOf(action.type) >= 0) {
if (getSelectedElement(getState())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this the same as prevPage from above (which you're also using in the else condition)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prevPage is bound to the result of getSelectedPage, not getSelectedElement to which the comment seems attached.

In any case, the overall point about common subexpression elimination is true. I had a provisional commit, which extracts out all the getState() etc. calls in this file, in some cases, reused like 10 times. I ended up not pushing it because this middleware file is mostly going away if the local (workpadPage) state based approach proves solid, and there is no notable perf difference.

Also, my mental model is slightly hazy if there are middleware statements that dispatch Redux actions: the dispatched action will re-execute the middleware part (I believe synchronously), and coming back from that dispatch to the original middleware call, what you have in getState and what you might have originally bound getState to might deviate. Ideally it's not the case (ie. calling getState from within the same execution of the middleware function should yield the snapshot) but again, I'm lacking a clear model, and I don't currently see how either way can be semantically clear (getState() giving old results, or giving new results both have their problems), so I'd be glad to hear or read info on this.

@monfera monfera merged commit c59db91 into master Mar 8, 2019
monfera added a commit to monfera/kibana that referenced this pull request Mar 8, 2019
* Fix: lose element selection on page flip

* Fix: remove selection in Redux too (PR feedback from Joe)
monfera added a commit to monfera/kibana that referenced this pull request Mar 8, 2019
* Fix: lose element selection on page flip

* Fix: remove selection in Redux too (PR feedback from Joe)
monfera added a commit to monfera/kibana that referenced this pull request Mar 8, 2019
* Fix: lose element selection on page flip

* Fix: remove selection in Redux too (PR feedback from Joe)
monfera added a commit that referenced this pull request Mar 8, 2019
* Fix: lose element selection on page flip

* Fix: remove selection in Redux too (PR feedback from Joe)
monfera added a commit that referenced this pull request Mar 8, 2019
* Fix: lose element selection on page flip

* Fix: remove selection in Redux too (PR feedback from Joe)
monfera added a commit that referenced this pull request Mar 8, 2019
* Fix: lose element selection on page flip

* Fix: remove selection in Redux too (PR feedback from Joe)
@monfera monfera deleted the lose-selection-on-page-flip branch March 8, 2019 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v6.7.0 v7.0.0 v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants