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

Multi selection: fix intermittent e2e failure #19865

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/block-editor/src/components/block-list/block-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,17 @@ function BlockPopover( {
let anchorRef = node;

if ( hasMultiSelection ) {
const bottomNode = blockNodes[ lastClientId ];

// Wait to render the popover until the bottom reference is available
// as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there something that triggers a re-render when the reference become available. What guarantee us that the rerender will happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are available through state provided by context. When there is a multi selection, the first and the last multi selected blocks both set their reference in this state, also creating a new array, so it causes a re-render for this component. The first and last node are not set at the same time though, so we have to wait until both are set.

if ( ! bottomNode ) {
return null;
}

anchorRef = {
top: blockNodes[ clientId ],
bottom: blockNodes[ lastClientId ],
top: node,
bottom: bottomNode,
};
}

Expand Down