Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Enable React StrictMode again #47639
Enable React StrictMode again #47639
Changes from all commits
532b1d9
f0fb47f
4cd93c7
207e16d
6a8a55f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Does it make sense to enable it in the
@wordpress/customize-widgets
package too?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.
Yes, that's a good catch, a forgotten legacy use of
render
:) I fixed it in f0fb47f.And I fixed it in a way that's IMO slightly better that how we do it in other apps. Instead of rendering
<StrictMode>
inside the top-level component, I use<StrictMode>
as the very top-level component, in therender
call.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.
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.
And now the e2e tests for
customize-widgets
started failing 🤦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'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
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 was able to figure out the failures and fix them.
One was a buggy adding and removing event listeners in
FocusControl
. TheuseEffect
cleanup function removes listener that was never added from an object that doesn't exist, leading to crash. Caused by React unmounting the effect and then mounting it again.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
speak()
. But there are twospeak()
calls racing with each other, editor mode switch and block selection, and concurrent mode reversed their order. I fixed that by searching for.is-navigate-mode
CSS selector instead.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.
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.
Seems like it's a different failure though. 🤔
I think the reported issue might be a legit flaky behavior of the customizer but I didn't verify it 😅
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 saw this block toolbar overlap when running this locally. Also, the
failures-artifact
zip file will have screenshots when this fails in CI, can be inspected.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.
Could we find another accessible selector for this? Using CSS selectors is generally not recommended.
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 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
aria-live
region used byspeak()
, but that gets quickly overwritten by the nextspeak()
call.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.
Some ideas:
speak()
call gets overridden, does it also mean that the message might not be accessible to screen readers or other assistive technologies? Will that be a concern in this case?data-testid
(or other public API if there's any), is it suitable here?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 🙂 .
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.
The problem here is that when you press Escape to enter the navigation mode, two things happen at once:
BlockSelectionButton
for the selected block appears (it's the black thing on the screenshot below) and it announces itself by saying "Paragraph Block. Row 1."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?