-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 ComplementaryArea's initial isActive state #47498
Conversation
Size Change: +220 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Flaky tests detected in 573ddf9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4084704360
|
packages/e2e-test-utils-playwright/src/editor/open-document-settings-sidebar.ts
Show resolved
Hide resolved
@WunderBart, the changes look good to me 👍 Do you have manual testing instructions, or should we rely on CI tests? |
Thanks for the review, @Mamaduka! 🙇 I think CI should tell us (based on the tests using the Settings sidebar) if the change is OK. 🤞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good fix 👍
The main issue is that on editor boot, enabling the sidebar is a two-step process:
- There is a server-supplied preference,
isComplementaryAreaVisible
. Server sends that in the initial HTML and when the sidebar is enabled, this value istrue
from the very beginning. - The sidebar has two tabs, with ids
edit-post/document
andedit-post/block
. Initially none is selected, and theactiveArea
isundefined
, although the sidebar is opened. - Only a bit later, in an effect, the
activeArea
is set to a valid value. Either in an effect that sets theisActiveByDefault
value, or in an effect that observes block selection and selects the document ("Post", "Template", ...) tab when no block is selected, and switches to "Block" once a block gets selected.
This PR catches that ambiguous "sidebar opened but no tab selected" situation and disables the toggle button while it lasts.
packages/e2e-test-utils-playwright/src/editor/open-document-settings-sidebar.ts
Show resolved
Hide resolved
725ad50
to
fd4c55d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but this fix might also have a positive impact for assistive technologies which they usually evaluate the context of the page as soon as possible for performance reasons. Anyway it LGTM! 💯
fd4c55d
to
1369279
Compare
The panel is always initially closed in mobile viewport
This makes more sense contextually. `expect` should be reserved for the test subject.
This is consistent with the current settings sidebar name in the editor.
For a short time, if the `isComplementaryAreaVisible` preference is set to true, the `activeArea` value is `undefined`. Let's disable the area toggle button until the area is activated properly. This will help with E2E stability because the framework will wait until the button is enabled, and can also help with a11y as it will correctly indicate the initial state of the toggle.
1369279
to
ed67d4d
Compare
This makes the area state values to be consistent.
39ae045
to
573ddf9
Compare
@@ -69,7 +69,7 @@ export function SidebarComplementaryAreaFills() { | |||
identifier={ sidebarName } | |||
title={ __( 'Settings' ) } | |||
icon={ isRTL() ? drawerLeft : drawerRight } | |||
closeLabel={ __( 'Close settings sidebar' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called Close settings
everywhere else, so it made sense to me to make it consistent.
👋 @kevin940726 @jsnajdr @talldan, I'd appreciate it if you could take another look - I needed to make some updates to address the persisting area visibility preference between viewports. |
👋 @kevin940726 friendly ping in case you missed the last one! Could you take another look at this one? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good to me 👍 Thanks!
What?
ComplementaryArea
component,Why?
The active complementary area identifier is initially unavailable as it needs to be loaded into the store. This leads to a situation where the initial
isActive
state of theComplementaryArea
component isfalse
and, after one or more cycles, becomestrue
.While this change doesn't really manifest itself visually (it lasts only a few milliseconds), it is a good practice in the E2E testing context because it reliably signals when the component is ready to interact.
For example, if an E2E test wants to open the
Editor settings
sidebar (which uses theComplementaryArea
component), it needs to check whether that sidebar is already opened before it clicks the toggle button. If that sidebar's initialisActive
state isfalse
, but the actual state istrue
(which will kick in with a delay), we might end up closing the sidebar instead if the click is late by a few milliseconds.Also, as @kevin940726 mentioned, this change "might also have a positive impact for assistive technologies, which they usually evaluate the context of the page as soon as possible for performance reasons."
How to test
The E2E tests should cover this change, so it shouldn't need manual testing.
Related
openDocumentSettingsSidebar
util not opening the sidebar #43506