-
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
iOS: Prevent accidental block hover #3139
Changes from 2 commits
b63154d
27a476a
cefd778
b501d9c
dd3ddc1
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 |
---|---|---|
|
@@ -72,6 +72,8 @@ class VisualEditorBlock extends Component { | |
this.onKeyDown = this.onKeyDown.bind( this ); | ||
this.onBlockError = this.onBlockError.bind( this ); | ||
this.insertBlocksAfter = this.insertBlocksAfter.bind( this ); | ||
this.onTouchStart = this.onTouchStart.bind( this ); | ||
this.onClick = this.onClick.bind( this ); | ||
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. What would be the diff between touch start and click here? Might it be better stick to touch events entirely to set 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 tried onTouchEnd but it fires too soon it needs to be after mousemove |
||
|
||
this.previousOffset = null; | ||
|
||
|
@@ -160,10 +162,17 @@ class VisualEditorBlock extends Component { | |
} | ||
} | ||
|
||
onTouchStart() { | ||
this.hadTouchStart = true; | ||
} | ||
onClick() { | ||
this.hadTouchStart = false; | ||
} | ||
|
||
maybeHover() { | ||
const { isHovered, isSelected, isMultiSelected, onHover } = this.props; | ||
|
||
if ( isHovered || isSelected || isMultiSelected ) { | ||
if ( isHovered || isSelected || isMultiSelected || this.hadTouchStart ) { | ||
return; | ||
} | ||
|
||
|
@@ -345,6 +354,8 @@ class VisualEditorBlock extends Component { | |
onMouseLeave={ onMouseLeave } | ||
className={ wrapperClassName } | ||
data-type={ block.name } | ||
onTouchStart={ this.onTouchStart } | ||
onClick={ this.onClick } | ||
{ ...wrapperProps } | ||
> | ||
<BlockDropZone index={ order } /> | ||
|
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.
MDN seems very wary of using
-webkit-overflow-scrolling
. Are we safe? Is there a risk of targeting unwanted platforms where this could have a bad impact? We could target this to iOS.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.
@mcsf only webkit should interpret this from the vendor prefix and body will have the
.mobile
class on for mobile devices? Have tested on iPad and Nexus tablet.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.
Indeed, but my concern was whether this could affect non-iOS WebKit agents negatively. However, if you've tested on a Nexus and feel confident about this, I can withdraw my question.
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.
Should we really target
.mobile
here? What is the connection between the two? Can we not just add it to.editor-layout__editor
?