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

Editor: Standardize reduced motion handling using media queries #68424

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

Conversation

himanshupathak95
Copy link
Contributor

@himanshupathak95 himanshupathak95 commented Dec 31, 2024

Part of: #68282

What?

Replace all instances of the reduce-motion mixin with standardized @media not (prefers-reduced-motion) media queries across the editor package components to improve code consistency and maintainability.

Testing Instructions

Test Document Bar and Tools:

  • Open the editor
  • Hover over the document bar buttons
  • Click the inserter toggle (+ button)
  • Verify smooth transitions with motion-enabled
  • Verify instant changes with reduced motion enabled

Test Publish Panel:

  • Click the publish/update button
  • Observe the panel slide-in
  • Verify smooth animation with motion-enabled
  • Verify instant appearance with reduced motion enabled

Screencast

Screen.Recording.2025-01-01.at.15.35.12.mov
Screen.Recording.2025-01-01.at.15.36.33.mov
Screen.Recording.2025-01-01.at.15.38.17.mov

@himanshupathak95 himanshupathak95 marked this pull request as ready for review January 1, 2025 12:03
Copy link

github-actions bot commented Jan 1, 2025

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: himanshupathak95 <[email protected]>
Co-authored-by: t-hamano <[email protected]>

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

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM!

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Package] Editor /packages/editor labels Jan 11, 2025
@himanshupathak95
Copy link
Contributor Author

Hi @t-hamano, Thanks for approving the PR.

✅ The storybook builds are successful

I will remove this in a follow-up PR which I am going to raise for this

This PR is ready to be merged now 🚀

@t-hamano
Copy link
Contributor

@himanshupathak95 Thanks for the update!

I will remove this in a follow-up PR which I am going to raise for this

Is there any reason not to address this in this PR? If we don't remove this code in this PR, we will end up with redundant code like this:

.editor-post-featured-image__actions {
	&:not(.editor-post-featured-image__actions-missing-image) {
		@include reduce-motion("transition");

		@media not (prefers-reduced-motion) {
			transition: opacity 50ms ease-out;
		}
	}
}

@himanshupathak95
Copy link
Contributor Author

@t-hamano, Thanks for the suggestion. I have removed the redundant mixin.

@t-hamano
Copy link
Contributor

@himanshupathak95 It looks like E2E tests are failing. I don't think this PR is the cause, but can you try rebasing this PR?

@himanshupathak95 himanshupathak95 force-pushed the update/editor-reduce-motion-media-queries branch from 80fbdba to 55d06fa Compare January 15, 2025 07:51
@himanshupathak95
Copy link
Contributor Author

himanshupathak95 commented Jan 15, 2025

Thanks @t-hamano, you are correct that the changes are unrelated to the E2E tests failing I have also rebased this PR but it is very unusual that the tests are still failing. I am looking into this.

@himanshupathak95
Copy link
Contributor Author

As per my understanding, All failures are related to clicking the Publish button in the editor.

The error is consistent across all failures:
TimeoutError: page.click: Timeout 10000ms exceeded
The button is visible but "outside of the viewport"

This seems to be an existing flaky test issue, unrelated to the changes.

@t-hamano
Copy link
Contributor

This seems to be an existing flaky test issue, unrelated to the changes.

First we need to check if this is the case. At least I have never seen this test fail on the trunk branch.

It would be a good idea to check the above points.

@himanshupathak95 himanshupathak95 force-pushed the update/editor-reduce-motion-media-queries branch from 55d06fa to 6a5d1d2 Compare January 17, 2025 07:14
@himanshupathak95 himanshupathak95 force-pushed the update/editor-reduce-motion-media-queries branch from 6a5d1d2 to 4b5ca8a Compare January 22, 2025 09:07
@himanshupathak95
Copy link
Contributor Author

@t-hamano, I have investigated the failing tests and ran them all locally. When run locally, the failing tests all pass. I have also rebased the PR, but the tests still fail.

@t-hamano
Copy link
Contributor

@himanshupathak95

I have investigated the failing tests and ran them all locally. When run locally, the failing tests all pass.

How did you test it? On my local machine, for example, the following test fails:

npm run test:e2e editor/blocks/comments.spec.js

@himanshupathak95
Copy link
Contributor Author

@t-hamano I followed the documentation for running a test for a specific file -

npm run test:e2e -- editor/blocks/comments.spec.js

Results -

image

@t-hamano
Copy link
Contributor

Did you run npm run dev before running the tests?

@himanshupathak95
Copy link
Contributor Author

Did you run npm run dev before running the tests?

I need to correct my previous update. The original dev server instance had become stale, which masked the test failures. I discovered they're failing after restarting the dev server. Upon running a fresh npm run dev instance, some tests are now failing.

Results 4 failed
[chromium] › editor/blocks/comments.spec.js:60:2 › Comments › Pagination links are working as expected 

[chromium] › editor/blocks/comments.spec.js:112:2 › Comments › Pagination links are not appearing if break comments is not enabled 

[chromium] › editor/blocks/comments.spec.js:181:2 › Comments › The editable block version is rendered if the legacy attribute is false 

[chromium] › editor/blocks/comments.spec.js:209:2 › Comments › The PHP version is rendered if the legacy attribute is true

Apologies for any confusion caused.

@t-hamano
Copy link
Contributor

If we can reproduce this issue locally, it must mean that this PR is causing the tests to fail.

I'm not sure why, but we might want to investigate which code is causing the issue or run in debug mode:

npm run test:e2e editor/blocks/comments.spec.js -- --debug

@himanshupathak95
Copy link
Contributor Author

himanshupathak95 commented Jan 22, 2025

@t-hamano After debugging and noticing the Publish button and the behavior of the pre-publish panel, I think the old mixing and the new media query handle things differently. The new media query is preventing the Playwright from being able to reliably click the "Publish" button during the animation/transition period.

So I tried this -

diff --git a/packages/editor/src/components/post-publish-panel/style.scss b/packages/editor/src/components/post-publish-panel/style.scss
index 36e6fa16df..d099f63e23 100644
--- a/packages/editor/src/components/post-publish-panel/style.scss
+++ b/packages/editor/src/components/post-publish-panel/style.scss
@@ -210,9 +210,10 @@
 		left: auto;
 		width: $sidebar-width + $border-width;
 		border-left: $border-width solid $gray-300;
-		transform: translateX(+100%);
+		transform: translateX(0);
 
 		@media not (prefers-reduced-motion) {
+			transform: translateX(+100%);
 			animation: editor-post-publish-panel__slide-in-animation 0.1s forwards;
 		}
 

and the failing tests are passing now. What are your thoughts on this?

@t-hamano
Copy link
Contributor

and the failing tests are passing now. What are your thoughts on this?

If you make this change, will the publish panel still work properly when prefers-reduced-motion is disabled?

Since prefers-reduced-motion is not enabled in the E2E tests, we need to manually test the opposite.

@himanshupathak95
Copy link
Contributor Author

@t-hamano After investigating and testing it, I can confirm that this was the issue.

The pre-publish panel was having issues while opening, which caused the tests to fail. This change fixes that and the tests are now passing -

Screen.Recording.2025-01-23.at.13.52.41.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Editor /packages/editor [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants