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: Reset focused fusion path to null whenever the edit-/preview-mode changes #3337

Merged

Conversation

grebaldi
Copy link
Contributor

fixes: #3335

The Problem

When focusing a node inside the <ContentCanvas/>, the associated fusionPath of that content element will be saved to the redux store. When the current edit-/preview-mode is then changed, said fusionPath is no longer valid (because the content element will be rendered through an entirely different path).

This confuses the <InlineUI/> component. It uses the stored fusionPath to locate the DOM node inside the <ContentCanvas/> that it attaches itself to. Since the fusionPath is invalid after the switch, the DOM node can longer be found and the <InlineUI/> becomes invisible.

The solution

The code responsible for locating nodes inside the <ContentCanvas/> can be found here:

export const findNodeInGuestFrame = (contextPath, fusionPath) => fusionPath ? findInGuestFrame(
`[data-__neos-node-contextpath="${contextPath}"][data-__neos-fusion-path="${fusionPath}"]`
) : findInGuestFrame(
`[data-__neos-node-contextpath="${contextPath}"]`
);

It anticipates situations in which no fusionPath is set (which is the case when selecting a node in the <ContentTree/> component for example). Basically, if there's no fusionPath it selects the first node that matches the focused contextPath, which I found quite acceptable for switching between edit-/preview-modes.

Therefore, I altered the CR.Nodes reducer to set the focused fusionPath to null whenever the UI.EditPreviewMode.SET action occurs. With this, the <InlineUI/> component no longer disappears when the edit-/preview-mode is switched.

@grebaldi grebaldi added Bug Label to mark the change as bugfix Accessibility 7.3 labels Jan 18, 2023
@grebaldi grebaldi linked an issue Jan 18, 2023 that may be closed by this pull request
@grebaldi
Copy link
Contributor Author

Hmm... I do not understand why the E2E tests fail (but they do so consistently). From the log I take that moving multiple nodes in the Document Tree via Drag and Drop leads to an unexpected state, but I cannot reproduce the issue.

@grebaldi
Copy link
Contributor Author

Well... The nth run did pass 😅

@crydotsnake crydotsnake self-requested a review January 21, 2023 13:57
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.

Thx! Works as expected 🙂

@crydotsnake crydotsnake requested a review from Sebobo January 21, 2023 14:15
Copy link
Member

@markusguenther markusguenther left a comment

Choose a reason for hiding this comment

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

Thanks @grebaldi

@markusguenther markusguenther merged commit 07df15a into neos:7.3 Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7.3 Accessibility Bug Label to mark the change as bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Inline Toolbar disappears when switching between edit-modes
3 participants