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

Block List: Hide hover effects when typing #5106

Merged
merged 3 commits into from
Feb 16, 2018
Merged

Conversation

aduth
Copy link
Member

@aduth aduth commented Feb 16, 2018

Regression introduced in #5078

This pull request seeks to resolve an issue where typing in a block does not dismiss hover effects. This behavior existed prior to #5078. Further, it avoids applying hover effects in more cases: when multi-selecting, or the block is selected (since block chrome is shown anyways).

Testing instructions:

  1. Navigate to Posts > Add New
  2. Insert a paragraph block
  3. Deselect the block by clicking the title
  4. Select the block by clicking it
  5. Keeping cursor atop the block, start typing
  6. Note that the hover effects are dismissed

Multi-selecting and singular selection shouldn't have hover effects applied
@aduth aduth added [Type] Bug An existing feature does not function as intended General Interface Parts of the UI which don't fall neatly under other labels. labels Feb 16, 2018
@aduth aduth added this to the 2.2 milestone Feb 16, 2018
const { isHovered } = this.state;

if ( isHovered || isMultiSelected || this.hadTouchStart ) {
if ( isHovered || isMultiSelected || isSelected ||
Copy link
Contributor

Choose a reason for hiding this comment

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

I explicitly removed isSelected here on a previous PR. Let me try to find the reason for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, to mimic the reducer behavior removed in #5078, we could hide the hover effects when the selected block changes the same way we're doing isTyping checks in this branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's not problematic anymore since #5050

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't really notice any bugs here aside from hitting a debugger breakpoint when I wasn't expecting it. The multi-selection one had some small issue previously where ending a multi-selection would cause hover effects on the starting and ending blocks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, to mimic the reducer behavior removed in #5078, we could hide the hover effects when the selected block changes the same way we're doing isTyping checks in this branch.

We might want this anyways. Noting another small issue is that when splitting a block while currently hovered over the original, hover effects appear above the original.

@@ -145,6 +145,10 @@ export class BlockListBlock extends Component {
) {
this.previousOffset = this.node.getBoundingClientRect().top;
}

if ( newProps.isTyping ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to compare with the previous prop or is unnecessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could, but it would have no impact, since hideHoverEffects guards against unnecessary setState, so even though this would repeatedly call hideHoverEffects, it would immediately abort because it's not hovered anyways.

Copy link
Contributor

Choose a reason for hiding this comment

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

hideHoverEffects is itself a no-op if the state is already set

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, GitHub didn't update fast enough to show Andrew's reply. :)

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM 👍

const { isHovered } = this.state;

if ( isHovered || isMultiSelected || this.hadTouchStart ) {
if ( isHovered || isMultiSelected || isSelected ||
this.props.isMultiSelecting || this.hadTouchStart ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, but the other props are extracted via destructuring assignment, while isMultiSelecting isn't.

Copy link
Member Author

Choose a reason for hiding this comment

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

Minor, but the other props are extracted via destructuring assignment, while isMultiSelecting isn't.

Our good friend no-shadow doesn't like the destructuring 😄

@aduth aduth merged commit 3b00e31 into master Feb 16, 2018
@aduth aduth deleted the fix/is-typing-hovered branch February 16, 2018 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants