Repository navigation
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. |
dsas
left a comment
There was a problem hiding this comment.
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.
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.
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.
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
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. |
dsas
left a comment
There was a problem hiding this comment.
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-editorfolder.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.logthroughout the code.Pre-merge Checklist