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 : Global styles revisions close button overlaps scrollbar #66456

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

Vrishabhsk
Copy link
Contributor

What?

  • Add breathing-space for the Close Button for Global Styles Revisions view to prevent the scrollbar from overlapping on the button

Why?

How?

  • Sets the position as relative for the Close Button when viewing revisions
  • Add spacing and alignment styles to match that of the Style Book Close Button view

Testing Instructions

  1. Open "Revisions" from the "Styles" sidebar
  2. Switch between "Revisions" and "Style Book" to see them lining up the exact same.
  3. See if the close button is overlapping the scrollbar

Screenshots or screencast

Before After
Screenshot 2024-10-25 at 2 11 59 PM Screenshot 2024-10-25 at 2 11 34 PM

Copy link

github-actions bot commented Oct 25, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Vrishabhsk <vrishabhsk@git.wordpress.org>
Co-authored-by: stokesman <presstoke@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@stokesman stokesman left a comment

Choose a reason for hiding this comment

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

Thanks for trying this out! I think the header space can work. Before we venture further it would be good to make sure @WordPress/gutenberg-design would agree it’s a good enough solution.


As for the current implementation in this branch—like you said, it doesn’t seem ideal to use the aria-label in a selector. Also, putting this revision-specific ruleset in the styles of EditorCanvasContainer seems unideal.

I think to do this more cleanly EditorCanvasContainer needs to support a className prop and the consuming components can leverage it for style overrides.

Here’s a diff where I started down that path and decided the Revisions doesn’t need to override the base close button’s styles but rather Style Book can override them. Also I didn’t stay too focused as there are some things in style book that could use some cleanup. So I'm adding this largely as a note that we could make a separate focused PR on that Style Book cleanup. The other changes seem like a good direction for this issue given the design change is favored of course.
diff --git a/packages/edit-site/src/components/editor-canvas-container/index.js b/packages/edit-site/src/components/editor-canvas-container/index.js
index ac1083e69a..de687128b9 100644
--- a/packages/edit-site/src/components/editor-canvas-container/index.js
+++ b/packages/edit-site/src/components/editor-canvas-container/index.js
@@ -1,3 +1,8 @@
+/**
+ * External dependencies
+ */
+import clsx from 'clsx';
+
 /**
  * WordPress dependencies
  */
@@ -46,6 +51,7 @@ function getEditorCanvasContainerTitle( view ) {
 
 function EditorCanvasContainer( {
 	children,
+	className,
 	closeButtonLabel,
 	onClose,
 	enableResizing = false,
@@ -114,7 +120,12 @@ function EditorCanvasContainer( {
 
 	return (
 		<EditorContentSlotFill.Fill>
-			<div className="edit-site-editor-canvas-container">
+			<div
+				className={ clsx(
+					'edit-site-editor-canvas-container',
+					className
+				) }
+			>
 				<ResizableEditor enableResizing={ enableResizing }>
 					{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
 					<section
diff --git a/packages/edit-site/src/components/editor-canvas-container/style.scss b/packages/edit-site/src/components/editor-canvas-container/style.scss
index 332c4cd123..9ea4fb2df8 100644
--- a/packages/edit-site/src/components/editor-canvas-container/style.scss
+++ b/packages/edit-site/src/components/editor-canvas-container/style.scss
@@ -17,27 +17,16 @@
 .edit-site-editor-canvas-container__section {
 	background: $white; // Fallback color, overridden by JavaScript.
 	border-radius: $radius-large;
-	bottom: 0;
-	left: 0;
+	height: 100%;
 	overflow: hidden;
-	position: absolute;
-	right: 0;
-	top: 0;
 	transition: all 0.3s; // Match .block-editor-iframe__body transition.
+	display: flex;
+	flex-direction: column;
 }
 
 .edit-site-editor-canvas-container__close-button {
-	position: absolute;
-	right: $grid-unit-10;
-	top: $grid-unit-10;
-	z-index: 2;
-	background: $white;
-
-	// Prevents Scrollbar overlapping the close button when viewing revisions.
-	&[aria-label="Close revisions"] {
-		position: relative;
-		top: 0;
-		margin: 8px 0;
-		left: calc(100% - #{$grid-unit-50});
-	}
+	flex: none;
+	align-self: flex-end;
+	margin-inline: 0 $grid-unit-10;
+	margin-block: $grid-unit-10;
 }
diff --git a/packages/edit-site/src/components/revisions/index.js b/packages/edit-site/src/components/revisions/index.js
index 5ce95872e0..2b5f9f81fc 100644
--- a/packages/edit-site/src/components/revisions/index.js
+++ b/packages/edit-site/src/components/revisions/index.js
@@ -72,6 +72,7 @@ function Revisions( { userConfig, blocks } ) {
 			title={ __( 'Revisions' ) }
 			closeButtonLabel={ __( 'Close revisions' ) }
 			enableResizing
+			className="edit-site-revisions"
 		>
 			<Iframe
 				className="edit-site-revisions__iframe"
diff --git a/packages/edit-site/src/components/style-book/index.js b/packages/edit-site/src/components/style-book/index.js
index 93bbc6311c..f8ae7fc1b0 100644
--- a/packages/edit-site/src/components/style-book/index.js
+++ b/packages/edit-site/src/components/style-book/index.js
@@ -200,12 +200,10 @@ function StyleBook( {
 			onClose={ onClose }
 			enableResizing={ enableResizing }
 			closeButtonLabel={ showCloseButton ? __( 'Close' ) : null }
+			className="edit-site-style-book"
 		>
 			<div
-				className={ clsx( 'edit-site-style-book', {
-					'is-wide': sizes.width > 600,
-					'is-button': !! onClick,
-				} ) }
+				className="edit-site-style-book__liner"
 				style={ {
 					color: textColor,
 					background: backgroundColor,
diff --git a/packages/edit-site/src/components/style-book/style.scss b/packages/edit-site/src/components/style-book/style.scss
index 773b4f10f5..7347325d15 100644
--- a/packages/edit-site/src/components/style-book/style.scss
+++ b/packages/edit-site/src/components/style-book/style.scss
@@ -1,14 +1,16 @@
 .edit-site-style-book {
 	// Ensure the style book fills the available vertical space.
 	// This is useful when the style book is used to fill a frame.
-	height: 100%;
-	&.is-button {
-		border-radius: $radius-large;
+	.edit-site-style-book__liner {
+		flex: 1;
+		display: flex;
+		flex-direction: column;
 	}
 
-	display: flex;
-	flex-direction: column;
-	align-items: stretch;
+	.edit-site-editor-canvas-container__close-button {
+		position: absolute;
+		z-index: 2;
+	}
 }
 
 .edit-site-style-book__iframe {
@@ -23,7 +25,6 @@
 
 .edit-site-style-book__tablist-container {
 	flex: none;
-
 	display: flex;
 	width: 100%;
 	padding-right: 56px;
@@ -32,6 +33,5 @@
 
 .edit-site-style-book__tabpanel {
 	flex: 1 0 auto;
-
 	overflow: auto;
 }

@jameskoster
Copy link
Contributor

Is this close button necessary? The revisions button already behaves like a toggle, and the < button exists. It's also pretty confusing if you have both Style Book and Revisions open – it's unclear what the x will close.

There's some higher-level design work around Styles happening in #66376 that we should probably keep an eye on too.

@Vrishabhsk
Copy link
Contributor Author

Hi @stokesman 👋. Thanks for helping out. I have added a couple of commits to add a className prop and refactored the styles according to it.

@stokesman
Copy link
Contributor

stokesman commented Oct 29, 2024

Is this close button necessary? The revisions button already behaves like a toggle, and the < button exists. It's also pretty confusing if you have both Style Book and Revisions open – it's unclear what the x will close.

Yeah, I'm not sure the close button is necessary. I also agree about the confusion when both Style Book and Revisions are open. I’m not sure removing or hiding the close button in Revisions would improve that yet it would fix its overlap with the scrollbar. From what I can see it wouldn’t interfere with the efforts in #66376 and just as a quick fix I think it’d be worth doing.

I have added a couple of commits to add a className prop and refactored the styles according to it.

Thanks! That’s a move in the right direction code-wise. Though, at this point it does seem like it’s simpler to not show the close button for Revisions. I think that can be as simple as removing the closeButtonLabel that Revisions passes to EditorCanvasContainer. Any other changes should be unnecessary for the issue at hand so probably should be reverted. Would you agree? Though, I'm not sure we need to push any more changes at this until it’s clear which direction seems best.

@stokesman
Copy link
Contributor

stokesman commented Oct 29, 2024

@afercia, I thought you might be interested in weighing in on this. It seems like the two options for a straightforward fix are:

  • Remove the close button for Revisions
  • Reserve space for the close button with an otherwise empty header area

It might be worth keeping in mind that either way Revisions can also be closed by pressing the escape key while focus is in the canvas.

@afercia afercia added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Package] Edit Site /packages/edit-site [Feature] Style Book labels Oct 30, 2024
@afercia
Copy link
Contributor

afercia commented Oct 30, 2024

@stokesman thanks for the ping.

I was wondering as well whether the close button is necessary. Besides the scrollbar issue, there's more to consider:

  • I'm not sure moving focus to the Close button is a good experience for keyboard / screen reader users. To me, that seems an assumption that when users enable the Style Book or Revisions they actually want to move inside the canvas. That isn't necessarily true as users may just want to switch the canvas to see its content and then switch it back. As such, I'd consider to explore keeping focus on the toggles.
  • In the Style Book canvas, the Close button is visually placed on the right and the tabs (Text, Colors, Theme, Media, Widgets) on the left. However, the DOM order is different as the Close button is first and the tabs come after. That introduces a mismatch between visual and DOM order that is a WCAG violation. Also, it's worth reminding the Close button can't be moved between the tabs and the tabpaeles because of Remove extraneous elements placed between Tabs and Tab panels #59013

Quoting from the issue:

because the Style Book has a header it avoids the issue.

Personally, between the two proposed options I'd opt for always having a header. However, the header should not be empty. It should contain a title: 'Style Book' and 'Revisions'. The Style Book tabs should be moved down to a second row.

@Vrishabhsk
Copy link
Contributor Author

Hi @afercia 👋

  • I have implemented a header for the ResizableEditor
  • I utilized the getEditorCanvasContainerTitle( editorCanvasContainerView ) value, which is used for aria-label, in the place of the Title.
Storybook Revisions Both Enabled
Screenshot 2024-11-01 at 2 03 44 PM Screenshot 2024-11-01 at 2 04 05 PM Screenshot 2024-11-01 at 2 04 19 PM

Let me know your thoughts on it. Thanks

@afercia afercia added the Needs Design Feedback Needs general design feedback. label Nov 5, 2024
@afercia
Copy link
Contributor

afercia commented Nov 5, 2024

@Vrishabhsk thank you. I'd totally support the new header and title. They solve a layout and an accessibility issue.

To me, all panels in the editor should have a visible title. The ResizableEditor in these two views looks like sort of a panel and to me it makes sense it shows a title.

I'd suggest to make the title a H2 heading but before any code change I suggest waiting for feedback from design.
Cc @WordPress/gutenberg-design

@stokesman
Copy link
Contributor

before any code change I suggest waiting for feedback from design

I second this. One thing that may come up is the header duplicates the title in the Document Bar.

Also while it’s a bit of a separate concern, when both the Style Book and Revisions are open it may increase the confusion about what the "close" button is going to do. The header says "Style Revisions" and the close button is generic "close" label makes it visually seem like it will close revisions but it will only close the Style Book.

style-book-revisions-close

The label for the Style Book’s close button could maybe be made more specific to help some and/or the title in the canvas container’s header made distinct when both are open—something like "Style Revisions / Style Book". Though that latter idea seems crummy to me compared to some better design solution which I haven’t been able to imagine yet.

@afercia
Copy link
Contributor

afercia commented Nov 11, 2024

One thing that may come up is the header duplicates the title in the Document Bar.

Yes, but I would argue that's a more general problem with the Document Bat that already happens for other cases. For example, the Post title is repeated 3 times in the UI. See point 3 of this issue description: #65238
I'd see the Document Bar as a separate issue that should be addressed separately, likely rethinking it entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Style Book [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Design Feedback Needs general design feedback. [Package] Edit Site /packages/edit-site [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants