Skip to content

Commit

Permalink
Fix cross selection delay in Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Oct 4, 2019
1 parent 116e89f commit cac2c20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/block-editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ class BlockList extends Component {
this.startClientId = clientId;
this.props.onStartMultiSelect();
window.addEventListener( 'mouseup', this.onSelectionEnd );

// Removing the contenteditable attributes within the block editor is
// essential for selection to work across editable areas. The edible
// hosts are removed, allowing selection to be extended outside the
// DOM element. `onStartMultiSelect` sets a flag in the store so the
// rich text components are updated, but the rerender may happen very
// slowly, especially in Safari for the blocks that are asynchonously
// rendered. To ensure the browser instantly removes the selection
// boundaries, we remove the contenteditable attributes manually.
Array.from(
document.querySelectorAll( '.block-editor-rich-text__editable' )
).forEach( ( node ) => {
node.removeAttribute( 'contenteditable' );
} );
}

/**
Expand Down

0 comments on commit cac2c20

Please sign in to comment.