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

iOS: Prevent accidental block hover #3139

Merged
merged 5 commits into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions editor/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
overflow-y: auto;
}

.mobile .editor-layout__editor {
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

only webkit should interpret this

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.

Copy link
Member

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?


.editor-layout .components-notice-list {
position: fixed;
top: 100px;
Expand Down
13 changes: 12 additions & 1 deletion editor/modes/visual-editor/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Copy link
Member

Choose a reason for hiding this comment

The 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 this.hadTouchStart?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 } />
Expand Down