-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gutenframe: Only try to select the PostLockedModal in appropriate conditions #83353
Gutenframe: Only try to select the PostLockedModal in appropriate conditions #83353
Conversation
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
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 don't know if I'm confused or if something is broken, but these console.logs never fire for me. Here's my testing diff:
--- apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.js
+++ apps/wpcom-block-editor/src/calypso/features/iframe-bridge-server.js
@@ -151,6 +151,7 @@ function handlePostLocked( calypsoPort ) {
const lockedDialogButtons = document.querySelectorAll(
'div.editor-post-locked-modal__buttons > a'
);
+ console.log('1. querying for modal buttons');
if ( lockedDialogButtons.length === 3 ) {
//signal the parent frame to navigate to All Posts
@@ -196,6 +197,7 @@ function handlePostLockTakeover( calypsoPort ) {
if ( isLocked && isLockTakeover ) {
const allPostsButton = document.querySelector( 'div.editor-post-locked-modal__buttons > a' );
+ console.log('2. querying for modal buttons');
if ( allPostsButton ) {
//handle All Posts button click event
lockedDialogButtons[ 0 ].setAttribute( 'target', '_parent' ); | ||
lockedDialogButtons[ 0 ].setAttribute( 'href', calypsoifyGutenberg.closeUrl ); | ||
} | ||
if ( lockedDialogButtons.length === 3 ) { |
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 confused, my dialog just has one button:
document.querySelectorAll('div.editor-post-locked-modal__buttons > a');
NodeList [ a.components-button.is-primary ]
0: <a class="components-button is-primary" href="edit.php?post_type=post">
length: 1
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.
Looking upstream, I think there an only ever be two buttons for the modal: https://github.com/WordPress/gutenberg/blob/187224a67b839ace8e9c42b85f351fda996a2361/packages/editor/src/components/post-locked-modal/index.js#L247
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 used to be three buttons, but changed to two with WordPress/gutenberg#37852, this probably needs updating. I still can't trigger it so maybe something else is outdated....I'll open an issue
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.
Oh actually one of my users is redirecting from the calypso url to the wp-admin url...let me figure that out. |
@dsas I haven't managed to test The other function works for me, with the correct redirect URL. |
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.
Even when testing according to instructions properly I can't seem to make the handlePostLocked
unsub fn ever have the if be true - my console.log never fires...I can't get it to pass with the original code either, isLocked
and isLockTakeover
are both true or the former is false and the latter undefined.
The handlePostLockTakeover
unsub fn manages to enter its if twice when isLocked and isLockTakeover are true.
None of the DOM look-ups are being spammed though and everything seems to work as it did before.
Reported on Slack: p1697833272217969-slack-C04DZ8M0GHW
Proposed Changes
PostLockedModal
's button, and only do it when the modal is supposed to be displayed.Testing Instructions
Note: using "Hide whitespace" would make the code easier to review, since most lines have simply been moved into a deeper nesting level.
wpcom-block-editor
folder.yarn dev --sync
.widgets.wp.com
.https://wordpress.com/post/{ SITE_FRAGMENT }/{ POST_ID }
.document.querySelector( 'div.editor-post-locked-modal__buttons > a' )
are only executed when the pre-conditions are cleared, and not every time the whole state updates.console.log
throughout the code.Pre-merge Checklist