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

Fix don't show hover effect if the ancestor of a block is multi-selected #7613

Merged
merged 1 commit into from Jun 29, 2018

Conversation

Projects
None yet
2 participants
@jorgefilipecosta
Member

jorgefilipecosta commented Jun 28, 2018

Description

Fixes: #7361

Before even if a parent block was multi-selected we still showed the hover effect on the children. This PR's corrects that.

How has this been tested?

I added some paragraphs and images and columns block. Added some blocks inside the columns. I multi-selected the columns and some blocks. I verified the hover effect does not appear on the children of the columns. But still appears in other blocks.

@jorgefilipecosta jorgefilipecosta self-assigned this Jun 28, 2018

let isMultiSelected = false;
while ( ancestorUid && ! isMultiSelected ) {
ancestorUid = getBlockRootUID( state, ancestorUid );
isMultiSelected = isBlockMultiSelected( state, ancestorUid );

This comment has been minimized.

@youknowriad

youknowriad Jun 28, 2018

Contributor

I believe we need some recursivity here in case we have more than one ancestor?

This comment has been minimized.

@jorgefilipecosta

jorgefilipecosta Jun 29, 2018

Member

Hi @youknowriad, yes we need to iterate over all the ancestors. We are doing it with the while ( ancestorUid && ! isMultiSelected ). The while cycle will only stop when we have no more ancestors or when we found a multi-selected ancestor.

This comment has been minimized.

@youknowriad

youknowriad Jun 29, 2018

Contributor

Oh gotcha missed it, I guess I was expecting a call to isAncestorMultiSelected

const { isHovered } = this.state;
if ( isHovered || isMultiSelected || isSelected ||

This comment has been minimized.

@youknowriad

youknowriad Jun 28, 2018

Contributor

I feel like we can drop this.props.isMultiSelecting entirely and replace it with isPartOfMultiSelection. Is there a use-case where we need both?

This comment has been minimized.

@jorgefilipecosta

jorgefilipecosta Jun 29, 2018

Member

The isMultiSelecting condition is required to avoid the hover effect when dragging the mouse to multi-select. There is a moment when adding a new block to a multi-selection where the block is not yet multi-selected and we are with the mouse over it without thus the hover would appear. The isMultiSelecting flag may be true while isPartOfMultiSelection maybe false.

This comment has been minimized.

@youknowriad

youknowriad Jun 29, 2018

Contributor

I don't think that's true because isPartOfMultiSelection = isMultiSelected || somethingElse I was not taking about isMultiSelecting

This comment has been minimized.

@jorgefilipecosta

jorgefilipecosta Jun 29, 2018

Member

Ah, you mean dropping isMultiSelected entirely. If that's case in function maybeHover we are already doing it and we don't use isMultiSelected. But for other functions e.g: related to the block focus we should continue to use isMultiSelected because they want to check if the specific block is selected and not if the block or one ancestor is selected.

This comment has been minimized.

@youknowriad

youknowriad Jun 29, 2018

Contributor

I took a look at the other tests and I believe isPartOfMultiSelection probably makes more sense there as well.

This comment has been minimized.

@jorgefilipecosta

jorgefilipecosta Jun 29, 2018

Member

Thank you for watching the use cases in detail. I applied your suggestion and I made some tests and the result looks great :)

@youknowriad

LGTM 👍

We might want to run npm run docs:build (rebase first) each time we add a selector/action

@jorgefilipecosta

This comment has been minimized.

Member

jorgefilipecosta commented Jun 29, 2018

Hi @youknowriad, unfortunately, I think our doc generation is not generating docs when createSelector is used, e.g: we don't have docs for getEditedPostContent. So in this case executing the command does not add the docs for the selector we are adding.

@youknowriad

This comment has been minimized.

Contributor

youknowriad commented Jun 29, 2018

@jorgefilipecosta Good catch, I'm limiting it to functions, I guess we can add also add the docs if it's a constant using createSelector it should be possible but let's leave this for a separate PR.

@jorgefilipecosta jorgefilipecosta merged commit eb95525 into master Jun 29, 2018

2 checks passed

codecov/project 47.08% (-0.03%) compared to 1f20cf8
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/hover-on-multiselected-nested-blocks branch Jun 29, 2018

@jorgefilipecosta jorgefilipecosta added this to the 3.2 milestone Jul 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment