-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix multiselection for float elements #11748
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import { compose } from '@wordpress/compose'; | |
*/ | ||
import BlockListBlock from './block'; | ||
import BlockListAppender from '../block-list-appender'; | ||
import { getBlockDOMNode } from '../../utils/dom'; | ||
|
||
class BlockList extends Component { | ||
constructor( props ) { | ||
|
@@ -78,8 +79,15 @@ class BlockList extends Component { | |
this.props.onStartMultiSelect(); | ||
} | ||
|
||
const boundaries = this.nodes[ this.selectionAtStart ].getBoundingClientRect(); | ||
const y = clientY - boundaries.top; | ||
const blockContentBoundaries = getBlockDOMNode( this.selectionAtStart ).getBoundingClientRect(); | ||
|
||
// prevent multi-selection from triggering when the selected block is a float | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there anything about this which is really specific to floats? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I thought I'd mention because it allows people to understand the reason for this code. |
||
// and the cursor is still between the top and the bottom of the block. | ||
if ( clientY >= blockContentBoundaries.top && clientY <= blockContentBoundaries.bottom ) { | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return; | ||
} | ||
|
||
const y = clientY - blockContentBoundaries.top; | ||
const key = findLast( this.coordMapKeys, ( coordY ) => coordY < y ); | ||
|
||
this.onSelectionChange( this.coordMap[ key ] ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any particular reason for the switch to
getBlockDOMNode
? Is there a hope to get rid of thisthis.nodes
value altogether?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is that the
this.nodes
refer to the parent dom element which has a height = 0 for floats and I wanted the element surrounding the actual content of a block.