-
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
Remove multi-selection header #2934
Changes from all commits
6ae545a
deec597
c20bb3d
5514202
7c82b00
58bd5f7
4c0954e
fdea571
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 |
---|---|---|
|
@@ -40,6 +40,7 @@ import { | |
import { | ||
getBlock, | ||
getBlockFocus, | ||
isMultiSelecting, | ||
getBlockIndex, | ||
getEditedPostAttribute, | ||
getMultiSelectedBlockUids, | ||
|
@@ -136,7 +137,6 @@ class VisualEditorBlock extends Component { | |
|
||
bindBlockNode( node ) { | ||
this.node = node; | ||
this.props.blockRef( node ); | ||
} | ||
|
||
setAttributes( attributes ) { | ||
|
@@ -256,8 +256,9 @@ class VisualEditorBlock extends Component { | |
} | ||
|
||
onPointerDown( event ) { | ||
// Not the main button (usually the left button on pointer device). | ||
if ( event.buttons !== 1 ) { | ||
// Not the main button. | ||
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button | ||
if ( event.button !== 0 ) { | ||
return; | ||
} | ||
|
||
|
@@ -306,12 +307,13 @@ class VisualEditorBlock extends Component { | |
// Generate the wrapper class names handling the different states of the block. | ||
const { isHovered, isSelected, isMultiSelected, isFirstMultiSelected, focus } = this.props; | ||
const showUI = isSelected && ( ! this.props.isTyping || focus.collapsed === false ); | ||
const isProperlyHovered = isHovered && ! this.props.isSelecting; | ||
const { error } = this.state; | ||
const wrapperClassname = classnames( 'editor-visual-editor__block', { | ||
'has-warning': ! isValid || !! error, | ||
'is-selected': showUI, | ||
'is-multi-selected': isMultiSelected, | ||
'is-hovered': isHovered, | ||
'is-hovered': isProperlyHovered, | ||
} ); | ||
|
||
const { onMouseLeave, onFocus, onReplace } = this.props; | ||
|
@@ -330,31 +332,37 @@ class VisualEditorBlock extends Component { | |
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */ | ||
return ( | ||
<div | ||
ref={ this.bindBlockNode } | ||
onKeyDown={ this.onKeyDown } | ||
onFocus={ this.onFocus } | ||
ref={ this.props.blockRef } | ||
onMouseMove={ this.maybeHover } | ||
onMouseEnter={ this.maybeHover } | ||
onMouseLeave={ onMouseLeave } | ||
className={ wrapperClassname } | ||
data-type={ block.name } | ||
tabIndex="0" | ||
aria-label={ blockLabel } | ||
{ ...wrapperProps } | ||
> | ||
<BlockDropZone index={ order } /> | ||
{ ( showUI || isHovered ) && <BlockMover uids={ [ block.uid ] } /> } | ||
{ ( showUI || isHovered ) && <BlockRightMenu uid={ block.uid } /> } | ||
{ ( showUI || isProperlyHovered ) && <BlockMover uids={ [ block.uid ] } /> } | ||
{ ( showUI || isProperlyHovered ) && <BlockRightMenu uids={ [ block.uid ] } /> } | ||
{ showUI && isValid && mode === 'visual' && <BlockToolbar uid={ block.uid } /> } | ||
|
||
{ isFirstMultiSelected && ( | ||
{ isFirstMultiSelected && ! this.props.isSelecting && | ||
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. Can you explain why do we need the 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.
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. 👍 Do you think it could be tracked in Redux's state instead of a local state? 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. Sure, we can do that. |
||
<BlockMover uids={ multiSelectedBlockUids } /> | ||
) } | ||
} | ||
{ isFirstMultiSelected && ! this.props.isSelecting && | ||
<BlockRightMenu | ||
uids={ multiSelectedBlockUids } | ||
focus={ true } | ||
/> | ||
} | ||
<div | ||
ref={ this.bindBlockNode } | ||
onKeyPress={ this.maybeStartTyping } | ||
onDragStart={ ( event ) => event.preventDefault() } | ||
onMouseDown={ this.onPointerDown } | ||
onKeyDown={ this.onKeyDown } | ||
onFocus={ this.onFocus } | ||
className="editor-visual-editor__block-edit" | ||
tabIndex="0" | ||
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. I'm a bit concerned about this change (moving the tabIndex here). Because we heavily rely on the 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. Confirmed arrow navigation is broken. 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. Hm, it's unfortunate that we rely on 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. I'll update the selector. 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. Yes, but I don't know honestly what's the best alternative would be. This is all related to focus management which is causing us a lot of trouble in several places. We'll have to rethink it entirely IMO:
I think we should tackle this clarification as soon as we can. 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. How can I resolve this PR? Should I remove the bug fixes for Firefox and Safari (also broken in master). 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. It relates more to the Arrow navigation which is causing issue with this PR. Maybe it's ok to do a temporary hack in this PR, adding a way to identify the block's tabbable element (className or attribute or something else) and update the 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. Ah, ok. I'll update the temporary hack in 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. Rewritten in dc9859f2935c5add1d4c10edf45ca916542ff4e1. 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.
Noting that I have a local work-in-progress branch which takes a stab at this with a few ideas:
As a work-in-progress, some of these ideas are still muddy, for example directionality of focus and shifting focus within the same focus context might be deserving of more controlled treatment within state. |
||
aria-label={ blockLabel } | ||
> | ||
<BlockCrashBoundary onError={ this.onBlockError }> | ||
{ isValid && mode === 'visual' && ( | ||
|
@@ -404,6 +412,7 @@ export default connect( | |
isFirstMultiSelected: isFirstMultiSelectedBlock( state, ownProps.uid ), | ||
isHovered: isBlockHovered( state, ownProps.uid ), | ||
focus: getBlockFocus( state, ownProps.uid ), | ||
isSelecting: isMultiSelecting( state ), | ||
isTyping: isTyping( state ), | ||
order: getBlockIndex( state, ownProps.uid ), | ||
multiSelectedBlockUids: getMultiSelectedBlockUids( state ), | ||
|
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.
Not related to this PR but I guess this means we could drop this line https://github.com/WordPress/gutenberg/pull/2934/files#diff-1d765b1a62f4ddc8c86819016031b8dfR23
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.
Yeah, was wondering why there were two calls. Not sure which to delete. The call here is not strictly necessary, it's only needed for the inspector I guess.
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.
No, actually it's necessary when we click on the toggle for a "hovered" block, we need to select it first to avoid issues when trying to click the menu icons.
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.
This is done.