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

BUGFIX: Check for unapplied inspector changes before allowing focus change via <SelectedElement/> #3501

Closed

Conversation

grebaldi
Copy link
Contributor

fixes: #3174

The problem

#3174 describes a way to bypass the "Unapplied Changes"-dialog that is supposed to prevent the user from losing pending inspector changes.

The user can focus a different node by using the <SelectedElement/> container that is always at the top of the inspector:
image

This works, because the "Unapplied Changes"-dialog is exclusively triggered by an overlay that appears, when there are pending changes, and covers the entire UI (after #3491 has been merged that is) except the inspector. Since the <SelectedElement/> container is part of the inspector, it is not covered by the overlay and thus allows the user to bypass the "Unapplied Changes"-dialog.

The solution

The first part of the solution introduces a new redux action to the inspector state called ELEMENT_WAS_SELECTED. (The naming is up for discussion, since it introduces past-tense as opposed to imperatives - which is more correct but runs counter the established convention. It may or may not be a confusing name anyway though - idk)

The inspector saga is then used to handle ELEMENT_WAS_SELECTED actions so that it first checks if there are pending changes in the inspector, triggers the "Unapplied Changes"-dialog if so, and - depending on the result of the latter - focuses the selected node or leaves the state untouched.

The second part of the solution concerns the handling of the Neos.Neos.Ui:ReloadContentOutOfBand server feedback. I noticed that if I selected an element and then clicked on "apply" in the "Unapplied Changes"-dialog, the node I've selected would be focused for a brief moment, after which the UI jumped back to the previously focused node.

The reason for this was, that the server feedback handler for Neos.Neos.Ui:ReloadContentOutOfBand wanted to re-focus the node it just reloaded, without checking whether it was still supposed to be focused. I added a check for that, so that no jumping occurs anymore.

@github-actions github-actions bot added Bug Label to mark the change as bugfix 7.3 labels May 22, 2023
@crydotsnake crydotsnake self-requested a review June 3, 2023 20:03
Copy link
Member

@crydotsnake crydotsnake left a comment

Choose a reason for hiding this comment

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

Just a few naming nitpicks. Otherwise this works fine!

@crydotsnake crydotsnake requested a review from Sebobo June 3, 2023 20:35
@crydotsnake crydotsnake requested a review from mhsdesign June 8, 2023 06:44
Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

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

Wow. i never expected that to be actually fixed, thank you for going through all the odd edge cases!!!

I will need to continue this review another time :)

@@ -41,6 +41,7 @@ export enum actionTypes {
DISCARD = '@neos/neos-ui/UI/Inspector/DISCARD',
ESCAPE = '@neos/neos-ui/UI/Inspector/ESCAPE',
RESUME = '@neos/neos-ui/UI/Inspector/RESUME',
ELEMENT_WAS_SELECTED = '@neos/neos-ui/UI/Inspector/ELEMENT_WAS_SELECTED',
Copy link
Member

Choose a reason for hiding this comment

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

im not sure that i would get without having this image in mind

that we are talking about the little dropdown up top ^^ - its easily forgettable. But then again the naming is scoped to the inspector so i think its still fine.

ill try to think of another name ;)

Comment on lines +569 to +575
const currentlyFocusedNodeContextPaths =
selectors.CR.Nodes.focusedNodePathsSelector(store.getState());

if (currentlyFocusedNodeContextPaths.includes(contextPath)) {
store.dispatch(actions.CR.Nodes.focus(contextPath, fusionPath));
store.dispatch(actions.UI.ContentCanvas.requestScrollIntoView(true));
}
Copy link
Member

Choose a reason for hiding this comment

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

that seems to be part of the second fix you mentioned that i dont really understand at first glance. But i will try some debugging and see if i can then make sense of those lines plus your description ;)

@grebaldi
Copy link
Contributor Author

Closed in favor of #3491

@grebaldi grebaldi closed this Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7.3 Bug Label to mark the change as bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Escape "Unapplied changes" when using "Selected element" to navigate to other Node
3 participants