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

Fix regression with column block being selected. #14876

Merged
merged 2 commits into from
Apr 11, 2019
Merged
Changes from all 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
32 changes: 16 additions & 16 deletions packages/block-library/src/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,26 @@ div.block-core-columns.is-vertically-aligned-bottom {
right: 0;
}

// The empty state of a columns block has the default appenders.
// Since those appenders are not blocks, the parent, actual block, appears "hovered" when hovering the appenders.
// Because the column shouldn't be hovered as part of this temporary passthrough, we unset the hover style.
.wp-block-columns [data-type="core/column"].is-hovered {
> .block-editor-block-list__block-edit::before {
content: none;
}

.block-editor-block-list__breadcrumb {
display: none;
}
}

// In absence of making the individual columns resizable, we prevent them from being clickable.
// This makes them less fiddly. @todo: This should be revisited as the interface is refined.
.wp-block-columns [data-type="core/column"] {
pointer-events: none;

// The empty state of a columns block has the default appenders.
// Since those appenders are not blocks, the parent, actual block, appears "hovered" when hovering the appenders.
// Because the column shouldn't be hovered as part of this temporary passthrough, we unset the hover style.
&.is-hovered {
> .block-editor-block-list__block-edit::before {
content: none;
}

.block-editor-block-list__breadcrumb {
display: none;
}
// This selector re-enables clicking on any child of a column block.
.block-core-columns .block-editor-block-list__layout {
pointer-events: all;
}
}

// This selector re-enables clicking on any child of a column block.
:not(.components-disabled) > .wp-block-columns > .editor-inner-blocks > .editor-block-list__layout > [data-type="core/column"] > .editor-block-list__block-edit > * {
Copy link
Member

@aduth aduth Apr 9, 2019

Choose a reason for hiding this comment

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

Will we be causing an issue in the fact we're removing this specific handling for "Disabled" context?

From #11620:

It improves the UI around reusable blocks, by fixing an issue where even though contents should be disabled when in a reusable block, it was still selectable if there were nested blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks so much for this reminder. I did forget to test reusable blocks. Thankfully this seems to work also as intended. GIF:

gif

Here's how the code works:

.wp-block-columns [data-type="core/column"] {
	pointer-events: none;

	// This selector re-enables clicking on any child of a column block.
	.block-core-columns .block-editor-block-list__layout {
		pointer-events: all;
	}
}

Basically the column block, and every child below, is made unclickable.

After that, only the .block-editor-block-list__layout element that is a child, is made clickable again, which appears to be sufficient.

The specificity is lower than that of any of the .components-disabled blocks, such as archives or reusable blocks, therefore the pointer-events: none attached to those is unaffected.

In the previous version, both > and * were used to make elements clickable again, which was both unnecessary because of inheritance, but also too specific, needing the :not selector.

pointer-events: all;
}