-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
Multi-selecting and singular selection shouldn't have hover effects applied
const { isHovered } = this.state; | ||
|
||
if ( isHovered || isMultiSelected || this.hadTouchStart ) { | ||
if ( isHovered || isMultiSelected || isSelected || |
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.
I explicitly removed isSelected
here on a previous PR. Let me try to find the reason for this.
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.
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.
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.
I think it's not problematic anymore since #5050
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.
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.
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.
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 ) { |
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.
Don't we need to compare with the previous prop or is unnecessary?
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.
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.
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.
hideHoverEffects
is itself a no-op if the state is already set
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.
Ah, GitHub didn't update fast enough to show Andrew's reply. :)
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.
LGTM 👍
const { isHovered } = this.state; | ||
|
||
if ( isHovered || isMultiSelected || this.hadTouchStart ) { | ||
if ( isHovered || isMultiSelected || isSelected || | ||
this.props.isMultiSelecting || this.hadTouchStart ) { |
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.
Minor, but the other props are extracted via destructuring assignment, while isMultiSelecting
isn't.
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.
Minor, but the other props are extracted via destructuring assignment, while
isMultiSelecting
isn't.
Our good friend no-shadow
doesn't like the destructuring 😄
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: