Skip to content

Conversation

@jeyip
Copy link
Contributor

@jeyip jeyip commented Sep 24, 2020

Description

The document title in the site editor isn't center aligned with content when the new navigation sidebar is open.

How has this been tested?

  1. Set up the site editor in a local dev environment
  2. Navigate to the site editor from the wp-admin sidebar
  3. Note the centered positioning of the topbar document title
  4. Open the new navigation sidebar by clicking on the wordpress icon in the top left corner of the screen
  5. Note that the positioning of the topbar document title is still centered with editor content

Screenshots

Before

Before

After

After

Types of changes

Bug fix which addresses #25629.

Elaborating more on the approach, there are two scenarios we have to support.

  1. When the nav sidebar is closed, we want to center the document title with editor content, which happens to match the browser viewport.
  2. When the nav sidebar is open, the center of editor content no longer matches the center of the browser viewport. The center becomes a segment of the viewport.

Moving the nav sidebar component outside of the edit-site-header_start wrapper with the existing flex layout solves # 2. To handle situation # 1, I absolutely position the document title in the middle of the page. Opening the sidebar just removes all references to absolute positioning. Closing the sidebar reintroduces absolute positioning.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@jeyip jeyip added [Type] Bug An existing feature does not function as intended [Feature] Full Site Editing labels Sep 24, 2020
@jeyip jeyip requested a review from youknowriad as a code owner September 24, 2020 21:27
@jeyip jeyip self-assigned this Sep 24, 2020
@github-actions
Copy link

github-actions bot commented Sep 24, 2020

Size Change: +74 B (0%)

Total Size: 1.17 MB

Filename Size Change
build/block-editor/style-rtl.css 11.1 kB +3 B (0%)
build/block-editor/style.css 11.1 kB +3 B (0%)
build/edit-site/index.js 20.4 kB +33 B (0%)
build/edit-site/style-rtl.css 3.78 kB +18 B (0%)
build/edit-site/style.css 3.78 kB +17 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.52 kB 0 B
build/api-fetch/index.js 3.35 kB 0 B
build/autop/index.js 2.72 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 8.61 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/index.js 129 kB 0 B
build/block-library/editor-rtl.css 8.6 kB 0 B
build/block-library/editor.css 8.6 kB 0 B
build/block-library/index.js 135 kB 0 B
build/block-library/style-rtl.css 7.65 kB 0 B
build/block-library/style.css 7.64 kB 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-default-parser/index.js 1.78 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 47.5 kB 0 B
build/components/index.js 168 kB 0 B
build/components/style-rtl.css 15.4 kB 0 B
build/components/style.css 15.4 kB 0 B
build/compose/index.js 9.42 kB 0 B
build/core-data/index.js 12 kB 0 B
build/data-controls/index.js 1.27 kB 0 B
build/data/index.js 8.42 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 4.42 kB 0 B
build/edit-navigation/index.js 10.7 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.25 kB 0 B
build/edit-post/style.css 6.24 kB 0 B
build/edit-widgets/index.js 18.7 kB 0 B
build/edit-widgets/style-rtl.css 3.03 kB 0 B
build/edit-widgets/style.css 3.03 kB 0 B
build/editor/editor-styles-rtl.css 492 B 0 B
build/editor/editor-styles.css 493 B 0 B
build/editor/index.js 45.5 kB 0 B
build/editor/style-rtl.css 3.83 kB 0 B
build/editor/style.css 3.82 kB 0 B
build/element/index.js 4.44 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.49 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 1.74 kB 0 B
build/html-entities/index.js 621 B 0 B
build/i18n/index.js 3.55 kB 0 B
build/is-shallow-equal/index.js 709 B 0 B
build/keyboard-shortcuts/index.js 2.39 kB 0 B
build/keycodes/index.js 1.85 kB 0 B
build/list-reusable-blocks/index.js 3.02 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.12 kB 0 B
build/notices/index.js 1.69 kB 0 B
build/nux/index.js 3.27 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.44 kB 0 B
build/primitives/index.js 1.34 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/rich-text/index.js 13 kB 0 B
build/server-side-render/index.js 2.6 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.24 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.74 kB 0 B
build/warning/index.js 1.13 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

This fixes it, but I'm a little confused regarding the extra wrappers, classnames, and added style rules in general. Simply moving the MainDashboardButton.Slot out of the edit-site-header_start wrapper solves the issue on my end.

@noahtallen
Copy link
Member

i thought that approach might fix it too, but since the side button is no longer part of edit-site-header_start, it is centered based on the rest of the elements. so it's a little bit off center:

Screen Shot 2020-09-24 at 5 45 13 PM

(I think that could be fixed by adding absolute and some padding)

@Addison-Stavlo
Copy link
Contributor

it is centered based on the rest of the elements. so it's a little bit off center

Ahhh yeah! I see that now.

@jeyip
Copy link
Contributor Author

jeyip commented Sep 25, 2020

This fixes it, but I'm a little confused regarding the extra wrappers, classnames, and added style rules in general.

I updated the classes because they were previously based on positioning (start, center, end). With this fix, .edit-site-header_start, wouldn't be the start of the header anymore. It would appear after the sidebar toggle.

I don't feel strongly about the changes though, so if we feel like they're unintuitive, I'm happy to revert them. @Addison-Stavlo

@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Sep 25, 2020

so if we feel like they're unintuitive, I'm happy to revert them.

Actually regarding the name changes themselves they make sense to me! I was just confused why there a handful of things changing when moving that sidebar out of the wrapper seemed to solve the issue (which it really didn't as Noah pointed out).

@jeyip
Copy link
Contributor Author

jeyip commented Sep 25, 2020

I added a few notes to the PR subheading "Types of Changes" to elaborate more on what the additional styling is meant to do

@noahtallen
Copy link
Member

When the nav sidebar is closed, we want to center the document title in the browser viewport.
When the nav sidebar is open, we want to center the document title with editor content.

A nitpicky point on this is that we're really trying to align with editor content all the time (I think). It just so happens that it matches the viewport when it's fullscreen :)

@david-szabo97
Copy link
Member

A nitpicky point on this is that we're really trying to align with editor content all the time (I think). It just so happens that it matches the viewport when it's fullscreen :)

If we have a scrollbar in the content then the document title is a little bit off. Since the editor's content container's width is smaller with a few pixels because of the scrollbar.

Without scrollbar
image

With scrollbar
image

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

One thing I am noticing is the difference in overlapping behavior on smaller screen widths / devices.

With these changes, when we reduce the screen width the items on the left overlap our name panel:
new-overlap-sized

On the current master branch, this is prevented given how the style rules are set:
current-non-overlap

It would be nice to preserve this behavior, however it sounds like the double-dropdown that it is conflicting with will be removed in the future and I don't think there is an issue with the remainder of the items on the left (unless more are added in the future) as the top toolbar will disappear before we get to that narrow of a screen width. Given that I am not sure how concerning this should be. 🤔

@jeyip
Copy link
Contributor Author

jeyip commented Sep 25, 2020

If we have a scrollbar in the content then the document title is a little bit off. Since the editor's content container's width is smaller with a few pixels because of the scrollbar.

It would be nice to preserve this behavior, however it sounds like the double-dropdown that it is conflicting with will be removed in the future and I don't think there is an issue with the remainder of the items on the left (unless more are added in the future)

@david-szabo97 @Addison-Stavlo Great calllouts. I'll see if I can't address them or think of an alternative approach altogether to center the document title.

$button-size-small: 24px;
$header-height: 60px;
$panel-header-height: $grid-unit-60;
$nav-sidebar-width: 300px;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note:

I'd prefer to scope this variable to the site editor package (in a new _variables.scss in src/edit_site), but it looks like the prevailing convention is to add variables to this global base-styles stylesheet. If anyone knows otherwise, I'm happy to make changes.

@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Sep 25, 2020

Thinking more about this:

If we have a scrollbar in the content then the document title is a little bit off. Since the editor's content container's width is smaller with a few pixels because of the scrollbar.

I don't think we should be too concerned with this side of things. Consider that many users may often have the 'block-inspector' toolbar on the right hand side of the editor open a majority of the time, this shifts the editor canvas to the left by a the width of that sidebar. We probably shouldn't be worried about it being perfectly centered over the editor canvas in all cases, but centered with respect to the topbar area/items itself?

@jeyip
Copy link
Contributor Author

jeyip commented Sep 28, 2020

We probably shouldn't be worried about it being perfectly centered over the editor canvas in all cases, but centered with respect to the topbar area/items itself?

That's a good observation. I never noticed that opening the block settings sidebar changes content width.

many users may often have the 'block-inspector' toolbar on the right-hand side of the editor open a majority of the time

Given this information, addressing the scrollbar width seems less important. I do, however, think that we should fix the problem eventually. I imagine that there is still a large contingent of users that do not have block settings open when editing content. If they have a scrollbar permanently displayed, the document title will always be slightly misaligned.

How would we feel about creating a separate issue that's lower priority and handling the scrollbar in the future? @david-szabo97 @Addison-Stavlo

Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

yeah, I think the margin causes the center div to be pushed over further than it should be when the distance between "left" and "right" is small enough. So this makes things messy at even medium-sized viewports.

I also noticed this issue:
Screen Shot 2020-09-28 at 3 40 35 PM

@jeyip
Copy link
Contributor Author

jeyip commented Sep 29, 2020

@noahtallen @Addison-Stavlo I updated the styling. The title should be centering correctly and all problems should be addressed, except the misalignment when a permanent scrollbar is present that @david-szabo97 called out. I elaborate on that here.

@david-szabo97
Copy link
Member

Given this information, addressing the scrollbar width seems less important. I do, however, think that we should fix the problem eventually. I imagine that there is still a large contingent of users that do not have block settings open when editing content. If they have a scrollbar permanently displayed, the document title will always be slightly misaligned.
How would we feel about creating a separate issue that's lower priority and handling the scrollbar in the future?

Yep! This is kinda out of scope for this PR. Let's do it separately.

Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

other than the one thing about adding the classname to the body tag, I think this is about ready to go!

I'm noticing it still has two issues, but they already exist, so they don't have to block this.

The first is that the title looks off-center when the right sidebars are open. I know it's still centered in the expected spot, but it just looks visually weird. I'm unsure what our expectations should be for this, so I think we can leave it be for now.
Screen Shot 2020-09-29 at 10 28 29 AM

This is probably a bug with the nav sidebar rather than this, but at smallish viewports, the size of the sidebar in the header is different from the size of the sidebar in the body
Screen Shot 2020-09-28 at 3 40 35 PM

@jeyip jeyip force-pushed the fix/document-title-misalignment-with-open-sidebar branch from cb386d9 to f3b9863 Compare September 29, 2020 18:11
@jeyip jeyip force-pushed the fix/document-title-misalignment-with-open-sidebar branch from f3b9863 to a2d40e6 Compare September 29, 2020 18:33
@jeyip
Copy link
Contributor Author

jeyip commented Sep 29, 2020

The first is that the title looks off-center when the right sidebars are open. I know it's still centered in the expected spot, but it just looks visually weird. I'm unsure what our expectations should be for this, so I think we can leave it be for now.

The same thing happens when the inserter sidebar is opened 🙃

@jeyip
Copy link
Contributor Author

jeyip commented Sep 29, 2020

Created an issue for the scrollbar misalignment @david-szabo97 #25716

@noahtallen
Copy link
Member

nice, the new body class is looking good! Left a nitpicky comment about code location, but this is ready to merge whenever you like ;) :shipit:

@jeyip jeyip merged commit 004a32e into master Sep 29, 2020
@jeyip jeyip deleted the fix/document-title-misalignment-with-open-sidebar branch September 29, 2020 23:41
@github-actions github-actions bot added this to the Gutenberg 9.2 milestone Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants