From 98f7ead7e81492a54048ff7c6f2b000526ac6227 Mon Sep 17 00:00:00 2001 From: Shekhar Wagh Date: Wed, 25 Mar 2026 00:22:15 +0000 Subject: [PATCH 1/4] RTC: Fix stuck "Join" link in post list when lock expires Always render both "Edit" and "Join" as separate spans in the row action link and toggle visibility via CSS using the .wp-collaborative-editing class the heartbeat already manages. Replaces aria-label with screen-reader-text spans so the accessible name stays in sync with the visible text across lock state changes. --- backport-changelog/7.0/11346.md | 3 ++ lib/compat/wordpress-7.0/collaboration.php | 57 ++++++++++++++++------ 2 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 backport-changelog/7.0/11346.md diff --git a/backport-changelog/7.0/11346.md b/backport-changelog/7.0/11346.md new file mode 100644 index 00000000000000..f660e8a8429293 --- /dev/null +++ b/backport-changelog/7.0/11346.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/11346 + +* https://github.com/WordPress/gutenberg/pull/76795 diff --git a/lib/compat/wordpress-7.0/collaboration.php b/lib/compat/wordpress-7.0/collaboration.php index 714a87e99d19c5..d37d24d4f370b8 100644 --- a/lib/compat/wordpress-7.0/collaboration.php +++ b/lib/compat/wordpress-7.0/collaboration.php @@ -233,7 +233,8 @@ function gutenberg_filter_locked_posts_heartbeat_for_rtc( $response ) { * * Also re-enables checkboxes and row actions that WordPress core hides for * locked posts, since collaborative editing means the post is not exclusively - * locked. + * locked. Toggles "Edit" / "Join" action link text via the + * `.wp-collaborative-editing` class that the heartbeat already manages. */ function gutenberg_post_list_collaboration_styles() { ?> @@ -261,6 +262,20 @@ function gutenberg_post_list_collaboration_styles() { .wp-locked .row-actions .inline { display: revert; } + /* + * Toggle "Edit" / "Join" action link text based on lock state. + * The heartbeat adds/removes .wp-collaborative-editing on the row, + * so CSS handles the swap without needing JS to rewrite link text. + */ + .join-action-text { + display: none; + } + .wp-collaborative-editing .edit-action-text { + display: none; + } + .wp-collaborative-editing .join-action-text { + display: inline; + } ID ); - if ( ! $lock_holder ) { + if ( ! isset( $actions['edit'] ) ) { return $actions; } - if ( isset( $actions['edit'] ) ) { - $actions['edit'] = preg_replace( - '/>Edit' . esc_html__( 'Join', 'gutenberg' ) . '<', - $actions['edit'] - ); - } + $title = _draft_or_post_title( $post->ID ); + + $link_text = ''; + $link_text .= ''; + /* translators: %s: Post title. */ + $link_text .= '' . sprintf( __( 'Edit “%s”' ), $title ) . ''; + $link_text .= ''; + $link_text .= ''; + /* translators: Action link text for a singular post in the post list. Can be any type of post. */ + $link_text .= ''; + /* translators: %s: Post title. */ + $link_text .= '' . sprintf( __( 'Join editing “%s”', 'gutenberg' ), $title ) . ''; + $link_text .= ''; + + $actions['edit'] = sprintf( + '%s', + get_edit_post_link( $post->ID ), + $link_text + ); return $actions; } From 5a475bd56e4c7db36418c892cd29716af19b0dda Mon Sep 17 00:00:00 2001 From: Shekhar Wagh Date: Wed, 25 Mar 2026 17:11:00 +0530 Subject: [PATCH 2/4] RTC: Fix checkbox not showing for locked posts in post list The CSS selectors used `.wp-locked` to override core's hidden checkbox, but core's list-tables.css uses `tr.wp-locked` which has higher specificity. The `display: revert` rule never took effect, leaving checkboxes hidden on locked rows. --- lib/compat/wordpress-7.0/collaboration.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/compat/wordpress-7.0/collaboration.php b/lib/compat/wordpress-7.0/collaboration.php index d37d24d4f370b8..6b6005b1843292 100644 --- a/lib/compat/wordpress-7.0/collaboration.php +++ b/lib/compat/wordpress-7.0/collaboration.php @@ -254,12 +254,14 @@ function gutenberg_post_list_collaboration_styles() { /* * Re-enable controls that core hides for locked posts, * since RTC allows collaborative editing. + * Must use `tr.wp-locked` to match core's specificity in + * list-tables.css and actually override its `display: none`. */ - .wp-locked .check-column label, - .wp-locked .check-column input[type="checkbox"] { + tr.wp-locked .check-column label, + tr.wp-locked .check-column input[type="checkbox"] { display: revert; } - .wp-locked .row-actions .inline { + tr.wp-locked .row-actions .inline { display: revert; } /* From b9685de9cdf695b87b3ac28b78baf87008092ff6 Mon Sep 17 00:00:00 2001 From: Shekhar Wagh Date: Thu, 26 Mar 2026 21:20:12 +0530 Subject: [PATCH 3/4] RTC: Use sprintf with multi-line template for action link markup --- lib/compat/wordpress-7.0/collaboration.php | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/compat/wordpress-7.0/collaboration.php b/lib/compat/wordpress-7.0/collaboration.php index 6b6005b1843292..3cf2db8dabac6d 100644 --- a/lib/compat/wordpress-7.0/collaboration.php +++ b/lib/compat/wordpress-7.0/collaboration.php @@ -324,22 +324,31 @@ function gutenberg_post_list_collaboration_row_actions( $actions, $post ) { $title = _draft_or_post_title( $post->ID ); - $link_text = ''; - $link_text .= ''; - /* translators: %s: Post title. */ - $link_text .= '' . sprintf( __( 'Edit “%s”' ), $title ) . ''; - $link_text .= ''; - $link_text .= ''; - /* translators: Action link text for a singular post in the post list. Can be any type of post. */ - $link_text .= ''; - /* translators: %s: Post title. */ - $link_text .= '' . sprintf( __( 'Join editing “%s”', 'gutenberg' ), $title ) . ''; - $link_text .= ''; - + /* + * Both "Edit" and "Join" labels are rendered. The visible label is + * toggled by CSS based on the row's `wp-collaborative-editing` class, + * which is added or removed by inline-edit-post.js in response to + * heartbeat ticks. + */ $actions['edit'] = sprintf( - '%s', + '' + . '' + . '' + . '%3$s' + . '' + . '' + . '' + . '%5$s' + . '' + . '', get_edit_post_link( $post->ID ), - $link_text + __( 'Edit' ), + /* translators: %s: Post title. */ + sprintf( __( 'Edit “%s”' ), $title ), + /* translators: Action link text for a singular post in the post list. Can be any type of post. */ + _x( 'Join', 'post list', 'gutenberg' ), + /* translators: %s: Post title. */ + sprintf( __( 'Join editing “%s”', 'gutenberg' ), $title ) ); return $actions; From 5e02f028b5724cf584c8d07fc074113062f222ff Mon Sep 17 00:00:00 2001 From: Shekhar Wagh Date: Thu, 26 Mar 2026 21:51:12 +0530 Subject: [PATCH 4/4] RTC: Target .wp-locked for Edit/Join toggle in compat layer The CSS was targeting .wp-collaborative-editing, a class only set by core 7.0's inline-edit-post.js. The compat layer runs on older versions where the heartbeat uses .wp-locked, so the toggle never worked. Since this CSS is only output when RTC is enabled, .wp-locked always means collaborative editing here. --- lib/compat/wordpress-7.0/collaboration.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/compat/wordpress-7.0/collaboration.php b/lib/compat/wordpress-7.0/collaboration.php index 3cf2db8dabac6d..0d595c07bf488e 100644 --- a/lib/compat/wordpress-7.0/collaboration.php +++ b/lib/compat/wordpress-7.0/collaboration.php @@ -266,16 +266,17 @@ function gutenberg_post_list_collaboration_styles() { } /* * Toggle "Edit" / "Join" action link text based on lock state. - * The heartbeat adds/removes .wp-collaborative-editing on the row, - * so CSS handles the swap without needing JS to rewrite link text. + * The heartbeat adds/removes .wp-locked on locked rows. This + * CSS only runs when RTC is enabled, so .wp-locked here always + * means collaborative editing, not exclusive locking. */ .join-action-text { display: none; } - .wp-collaborative-editing .edit-action-text { + .wp-locked .edit-action-text { display: none; } - .wp-collaborative-editing .join-action-text { + .wp-locked .join-action-text { display: inline; }