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

Try fix image block #21167

Merged
merged 3 commits into from
Mar 27, 2020
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
24 changes: 15 additions & 9 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
__experimentalImageSizeControl as ImageSizeControl,
__experimentalImageURLInputUI as ImageURLInputUI,
} from '@wordpress/block-editor';
import { Component, Fragment } from '@wordpress/element';
import { Component } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { getPath } from '@wordpress/url';
import { withViewportMatch } from '@wordpress/viewport';
Expand Down Expand Up @@ -509,17 +509,23 @@ export class ImageEdit extends Component {
</>
);

const AlignmentWrapper = needsAlignmentWrapper ? Block.div : Fragment;
const BlockContentWrapper = needsAlignmentWrapper
? 'figure'
: Block.figure;
// Disable reason: Each block can be selected by clicking on it
/* eslint-disable jsx-a11y/click-events-have-key-events */
return (
<>
{ controls }
<AlignmentWrapper>
<BlockContentWrapper className={ classes }>
<div
className={
// Ideally these classes are not needed, and ideally, we
// provide an alignment wrapper component that the block
// can wrap around the block or we build it into
// Block.*.
needsAlignmentWrapper
? 'wp-block block-editor-block-list__block'
Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally these classes are not needed, and ideally, we provide an alignment wrapper component that the block can wrap around the block.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why these are needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's another argument to absorb the alignment in Block.* for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this for now (with a comment) while we continue the work to improve alignments

Copy link
Member Author

Choose a reason for hiding this comment

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

It's needed so the div has the proper width and margins. Yes, we'd need to comment and continue with figuring out how to best proceed with the alignment issue.

: undefined
}
>
<Block.figure className={ classes }>
<ImageSize src={ url } dirtynessTrigger={ align }>
{ ( sizes ) => {
const {
Expand Down Expand Up @@ -697,8 +703,8 @@ export class ImageEdit extends Component {
) }

{ mediaPlaceholder }
</BlockContentWrapper>
</AlignmentWrapper>
</Block.figure>
</div>
</>
);
/* eslint-enable jsx-a11y/click-events-have-key-events */
Expand Down