Repository navigation
Enable React StrictMode again #47639
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
Changes from all commits
532b1d9
f0fb47f
4cd93c7
207e16d
6a8a55f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ import { | |
| store as coreStore, | ||
| useResourcePermissions, | ||
| } from '@wordpress/core-data'; | ||
| import { useMemo } from '@wordpress/element'; | ||
| import { StrictMode, useMemo } from '@wordpress/element'; | ||
| import { | ||
| BlockEditorKeyboardShortcuts, | ||
| CopyHandler, | ||
|
|
@@ -99,22 +99,26 @@ export default function WidgetAreasBlockEditorProvider( { | |
| ); | ||
|
|
||
| return ( | ||
| <ShortcutProvider> | ||
| <BlockEditorKeyboardShortcuts.Register /> | ||
| <KeyboardShortcuts.Register /> | ||
| <SlotFillProvider> | ||
| <ExperimentalBlockEditorProvider | ||
| value={ blocks } | ||
| onInput={ onInput } | ||
| onChange={ onChange } | ||
| settings={ settings } | ||
| useSubRegistry={ false } | ||
| { ...props } | ||
| > | ||
| <CopyHandler>{ children }</CopyHandler> | ||
| <ReusableBlocksMenuItems rootClientId={ widgetAreaId } /> | ||
| </ExperimentalBlockEditorProvider> | ||
| </SlotFillProvider> | ||
| </ShortcutProvider> | ||
| <StrictMode> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to enable it in the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's a good catch, a forgotten legacy use of And I fixed it in a way that's IMO slightly better that how we do it in other apps. Instead of rendering Because otherwise, React devtools show a warning that the top level component is not in strict mode. Because only its children are: A completely harmless warning, but still a warning.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And now the e2e tests for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😅 I've rerun them just in case it was a flaky run. Feel free to revert the change and leave it for another PR if you feel it introduces extra flakiness, though
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was able to figure out the failures and fix them. One was a buggy adding and removing event listeners in Then there was a check if the editor is in navigation mode, which was searching for dynamic "you are currently in navigation mode" text element, added by The last one is a pre-existing failure where the element to click on is obcured by block toolbar: This has been auto-reported in #38832 for almost a year. I fixed this by first clicking on the page text, unfocusing the editor and hiding the toolbar, and only then clicking on the blue round "edit widget" icon that's no longer obscured.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Seems like it's a different failure though. 🤔
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw this block toolbar overlap when running this locally. Also, the |
||
| <ShortcutProvider> | ||
| <BlockEditorKeyboardShortcuts.Register /> | ||
| <KeyboardShortcuts.Register /> | ||
| <SlotFillProvider> | ||
| <ExperimentalBlockEditorProvider | ||
| value={ blocks } | ||
| onInput={ onInput } | ||
| onChange={ onChange } | ||
| settings={ settings } | ||
| useSubRegistry={ false } | ||
| { ...props } | ||
| > | ||
| <CopyHandler>{ children }</CopyHandler> | ||
| <ReusableBlocksMenuItems | ||
| rootClientId={ widgetAreaId } | ||
| /> | ||
| </ExperimentalBlockEditorProvider> | ||
| </SlotFillProvider> | ||
| </ShortcutProvider> | ||
| </StrictMode> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -262,6 +262,7 @@ test.describe( 'Widgets Customizer', () => { | |
| await expect( firstParagraphBlock ).toBeFocused(); | ||
|
|
||
| // Expect to focus on a already focused widget. | ||
| await paragraphWidget.click(); // noop click on the widget text to unfocus the editor and hide toolbar | ||
| await editParagraphWidget.click(); | ||
| await expect( firstParagraphBlock ).toBeFocused(); | ||
|
|
||
|
|
@@ -272,6 +273,8 @@ test.describe( 'Widgets Customizer', () => { | |
| const editHeadingWidget = headingWidget.locator( | ||
| 'role=button[name="Click to edit this widget."i]' | ||
| ); | ||
|
|
||
| await headingWidget.click(); // noop click on the widget text to unfocus the editor and hide toolbar | ||
| await editHeadingWidget.click(); | ||
|
|
||
| const headingBlock = page.locator( | ||
|
|
@@ -463,9 +466,9 @@ test.describe( 'Widgets Customizer', () => { | |
| await page.keyboard.press( 'Escape' ); | ||
| await expect( | ||
| page.locator( | ||
| '*[aria-live="polite"][aria-relevant="additions text"] >> text=/^You are currently in navigation mode./' | ||
| 'css=.block-editor-block-list__layout.is-navigate-mode' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we find another accessible selector for this? Using CSS selectors is generally not recommended.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried, but this was the only indication in the HTML markup that the editor is in navigation mode. Previously this test used the "you are currently in navigation mode" text in the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some ideas:
Anyway, this isn't that important and more like a nitpick 😅. We might want to restrict CSS selectors in e2e tests in the long term though, it'd be good to start these discussions early 🙂 .
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The problem here is that when you press Escape to enter the navigation mode, two things happen at once:
Both happen at the same time, while handling the Escape key event. The order is determined by random things like which store listeners runs first or which update is scheduled to which microtask. Enabling concurrent mode reversed this order. What does the screen reader do in this case? I don't know. Does it say the first message and then the second? Or does it ignore the first one, because it disappeared very quickly? |
||
| ) | ||
| ).toHaveCount( 1 ); | ||
| ).toBeVisible(); | ||
| await expect( paragraphBlock ).toBeVisible(); | ||
| } ); | ||
|
|
||
|
|
||



Uh oh!
There was an error while loading. Please reload this page.