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

Post editor: fix title margin #46698

Merged
merged 2 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
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
10 changes: 3 additions & 7 deletions packages/e2e-tests/specs/editor/various/editor-modes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ describe( 'Editing modes (visual/HTML)', () => {

it( 'should switch between visual and HTML modes', async () => {
// This block should be in "visual" mode by default.
let visualBlock = await page.$$(
'.block-editor-block-list__layout .block-editor-block-list__block.rich-text'
);
let visualBlock = await page.$$( '[data-block].rich-text' );
expect( visualBlock ).toHaveLength( 1 );

// Change editing mode from "Visual" to "HTML".
Expand All @@ -33,7 +31,7 @@ describe( 'Editing modes (visual/HTML)', () => {

// Wait for the block to be converted to HTML editing mode.
const htmlBlock = await page.$$(
'.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea'
'[data-block] .block-editor-block-list__block-html-textarea'
);
expect( htmlBlock ).toHaveLength( 1 );

Expand All @@ -42,9 +40,7 @@ describe( 'Editing modes (visual/HTML)', () => {
await clickMenuItem( 'Edit visually' );

// This block should be in "visual" mode by default.
visualBlock = await page.$$(
'.block-editor-block-list__layout .block-editor-block-list__block.rich-text'
);
visualBlock = await page.$$( '[data-block].rich-text' );
expect( visualBlock ).toHaveLength( 1 );
} );

Expand Down
18 changes: 17 additions & 1 deletion packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ export default function VisualEditor( { styles } ) {
titleRef?.current?.focus();
}, [ isWelcomeGuideVisible, isCleanNewPost ] );

styles = useMemo(
() => [
...styles,
{
// We should move this in to future to the body.
css: `.edit-post-visual-editor__post-title-wrapper{margin-top:4rem}`,
},
],
[ styles ]
);

return (
<BlockTools
__unstableContentRef={ ref }
Expand Down Expand Up @@ -374,10 +385,15 @@ export default function VisualEditor( { styles } ) {
{ ! isTemplateMode && (
<div
className={ classnames(
// This wrapper div should have the same
// classes as the block list beneath.
'is-root-container',
'block-editor-block-list__layout',
'edit-post-visual-editor__post-title-wrapper',
{
'is-focus-mode': isFocusMode,
}
},
blockListLayoutClass
Copy link
Member Author

Choose a reason for hiding this comment

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

For TT3, these classes are enough to restore the padding, but some themes use block-editor-block-list__layout or is-root-container. We should just make sure we use the same classes as the root block list.

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, we also render the post title as a proper block, but that's a bit of a challenge right now.

) }
contentEditable={ false }
>
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/specs/editor/blocks/paragraph.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ test.describe( 'Paragraph', () => {
await page.keyboard.type( '1' );

const firstBlockTagName = await page.evaluate( () => {
return document.querySelector(
'.block-editor-block-list__layout .wp-block'
).tagName;
return document.querySelector( '[data-block]' ).tagName;
} );

// The outer element should be a paragraph. Blocks should never have any
Expand Down