Skip to content

Commit 0ea2bcb

Browse files
authored
Fix duplicate HTML IDs and missing form labels in modal blocks (#2083)
1 parent 8907507 commit 0ea2bcb

File tree

6 files changed

+60
-13
lines changed

6 files changed

+60
-13
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Fix duplicate HTML IDs and missing form labels in modal blocks

build/follow-me/render.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Activitypub\Blocks;
99
use Activitypub\Collection\Actors;
1010
use Activitypub\Collection\Followers;
11+
1112
use function Activitypub\is_activitypub_request;
1213

1314
if ( is_activitypub_request() || is_feed() ) {
@@ -96,7 +97,7 @@
9697
'data-wp-bind--aria-expanded' => 'context.modal.isOpen',
9798
'aria-label' => __( 'Follow me on the Fediverse', 'activitypub' ),
9899
'aria-haspopup' => 'dialog',
99-
'aria-controls' => 'modal-heading',
100+
'aria-controls' => $block_id . '-modal-title',
100101
'role' => 'button',
101102
'tabindex' => '0',
102103
)
@@ -118,9 +119,12 @@
118119
<?php esc_html_e( 'Copy and paste my profile into the search field of your favorite fediverse app or server.', 'activitypub' ); ?>
119120
</div>
120121
<div class="activitypub-dialog__button-group">
122+
<label for="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>" class="screen-reader-text">
123+
<?php esc_html_e( 'My Fediverse handle', 'activitypub' ); ?>
124+
</label>
121125
<input
122126
aria-readonly="true"
123-
id="profile-handle"
127+
id="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>"
124128
readonly
125129
tabindex="-1"
126130
type="text"
@@ -142,12 +146,15 @@ class="wp-element-button wp-block-button__link"
142146
<?php esc_html_e( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
143147
</div>
144148
<div class="activitypub-dialog__button-group">
149+
<label for="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>" class="screen-reader-text">
150+
<?php esc_html_e( 'Your Fediverse profile', 'activitypub' ); ?>
151+
</label>
145152
<input
146153
data-wp-bind--aria-invalid="context.isError"
147154
data-wp-bind--value="context.remoteProfile"
148155
data-wp-on--input="actions.updateRemoteProfile"
149156
data-wp-on--keydown="actions.handleKeyDown"
150-
id="remote-profile"
157+
id="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>"
151158
placeholder="<?php esc_attr_e( '@[email protected]', 'activitypub' ); ?>"
152159
type="text"
153160
/>
@@ -235,6 +242,7 @@ class="activitypub-profile__avatar u-photo"
235242
// Render the modal using the Blocks class.
236243
Blocks::render_modal(
237244
array(
245+
'id' => $block_id . '-modal',
238246
'content' => $modal_content,
239247
/* translators: %s: Profile name. */
240248
'title' => sprintf( esc_html__( 'Follow %s', 'activitypub' ), esc_html( $actor->get_name() ) ),

build/remote-reply/render.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
*/
77

88
use Activitypub\Blocks;
9+
use function Activitypub\is_activitypub_request;
10+
11+
if ( is_activitypub_request() || is_feed() ) {
12+
return;
13+
}
914

1015
/* @var array $attributes Block attributes. */
1116
$attributes = wp_parse_args( $attributes );
@@ -68,9 +73,12 @@
6873
<?php esc_html_e( 'Copy and paste the Comment URL into the search field of your favorite fediverse app or server.', 'activitypub' ); ?>
6974
</div>
7075
<div class="activitypub-dialog__button-group">
76+
<label for="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>" class="screen-reader-text">
77+
<?php esc_html_e( 'Comment URL', 'activitypub' ); ?>
78+
</label>
7179
<input
7280
aria-readonly="true"
73-
id="profile-handle"
81+
id="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>"
7482
readonly
7583
tabindex="-1"
7684
type="text"
@@ -92,12 +100,15 @@ class="wp-element-button wp-block-button__link"
92100
<?php esc_html_e( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
93101
</div>
94102
<div class="activitypub-dialog__button-group">
103+
<label for="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>" class="screen-reader-text">
104+
<?php esc_html_e( 'Your Fediverse profile', 'activitypub' ); ?>
105+
</label>
95106
<input
96107
data-wp-bind--aria-invalid="context.isError"
97108
data-wp-bind--value="context.remoteProfile"
98109
data-wp-on--input="actions.updateRemoteProfile"
99110
data-wp-on--keydown="actions.onInputKeydown"
100-
id="remote-profile"
111+
id="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>"
101112
placeholder="<?php esc_attr_e( '@[email protected]', 'activitypub' ); ?>"
102113
type="text"
103114
/>
@@ -139,6 +150,7 @@ class="activitypub-dialog__error"
139150
>
140151
<div class="activitypub-remote-profile" hidden data-wp-bind--hidden="!context.hasRemoteUser">
141152
<a
153+
href=""
142154
class="comment-reply-link activitypub-remote-profile__link"
143155
data-wp-bind--href="state.remoteProfileUrl"
144156
target="_blank"
@@ -172,7 +184,7 @@ class="comment-reply-link activitypub-remote-reply__link"
172184
data-wp-bind--aria-expanded="context.modal.isOpen"
173185
aria-label="<?php esc_attr_e( 'Reply on the Fediverse', 'activitypub' ); ?>"
174186
aria-haspopup="dialog"
175-
aria-controls="modal-heading"
187+
aria-controls="<?php echo esc_attr( $block_id . '-modal-title' ); ?>"
176188
role="button"
177189
tabindex="0"
178190
hidden
@@ -183,6 +195,7 @@ class="comment-reply-link activitypub-remote-reply__link"
183195
<?php
184196
Blocks::render_modal(
185197
array(
198+
'id' => $block_id . '-modal',
186199
'title' => __( 'Remote Reply', 'activitypub' ),
187200
'content' => $modal_content,
188201
)

includes/class-blocks.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ public static function render_reply_block( $attrs ) {
282282
public static function render_modal( $args = array() ) {
283283
$defaults = array(
284284
'content' => '',
285+
'id' => '',
285286
'is_compact' => false,
286287
'title' => '',
287288
);
@@ -300,7 +301,12 @@ class="activitypub-modal__overlay<?php echo \esc_attr( $args['is_compact'] ? ' c
300301
<div class="activitypub-modal__frame">
301302
<?php if ( ! $args['is_compact'] || ! empty( $args['title'] ) ) : ?>
302303
<div class="activitypub-modal__header">
303-
<h2 class="activitypub-modal__title"><?php echo \esc_html( $args['title'] ); ?></h2>
304+
<h2
305+
class="activitypub-modal__title"
306+
<?php if ( ! empty( $args['id'] ) ) : ?>
307+
id="<?php echo \esc_attr( $args['id'] . '-title' ); ?>"
308+
<?php endif; ?>
309+
><?php echo \esc_html( $args['title'] ); ?></h2>
304310
<button
305311
type="button"
306312
class="activitypub-modal__close wp-element-button wp-block-button__link"

src/follow-me/render.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
'data-wp-bind--aria-expanded' => 'context.modal.isOpen',
9898
'aria-label' => __( 'Follow me on the Fediverse', 'activitypub' ),
9999
'aria-haspopup' => 'dialog',
100-
'aria-controls' => 'modal-heading',
100+
'aria-controls' => $block_id . '-modal-title',
101101
'role' => 'button',
102102
'tabindex' => '0',
103103
)
@@ -119,9 +119,12 @@
119119
<?php esc_html_e( 'Copy and paste my profile into the search field of your favorite fediverse app or server.', 'activitypub' ); ?>
120120
</div>
121121
<div class="activitypub-dialog__button-group">
122+
<label for="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>" class="screen-reader-text">
123+
<?php esc_html_e( 'My Fediverse handle', 'activitypub' ); ?>
124+
</label>
122125
<input
123126
aria-readonly="true"
124-
id="profile-handle"
127+
id="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>"
125128
readonly
126129
tabindex="-1"
127130
type="text"
@@ -143,12 +146,15 @@ class="wp-element-button wp-block-button__link"
143146
<?php esc_html_e( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
144147
</div>
145148
<div class="activitypub-dialog__button-group">
149+
<label for="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>" class="screen-reader-text">
150+
<?php esc_html_e( 'Your Fediverse profile', 'activitypub' ); ?>
151+
</label>
146152
<input
147153
data-wp-bind--aria-invalid="context.isError"
148154
data-wp-bind--value="context.remoteProfile"
149155
data-wp-on--input="actions.updateRemoteProfile"
150156
data-wp-on--keydown="actions.handleKeyDown"
151-
id="remote-profile"
157+
id="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>"
152158
placeholder="<?php esc_attr_e( '@[email protected]', 'activitypub' ); ?>"
153159
type="text"
154160
/>
@@ -236,6 +242,7 @@ class="activitypub-profile__avatar u-photo"
236242
// Render the modal using the Blocks class.
237243
Blocks::render_modal(
238244
array(
245+
'id' => $block_id . '-modal',
239246
'content' => $modal_content,
240247
/* translators: %s: Profile name. */
241248
'title' => sprintf( esc_html__( 'Follow %s', 'activitypub' ), esc_html( $actor->get_name() ) ),

src/remote-reply/render.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
use Activitypub\Blocks;
9+
use function Activitypub\is_activitypub_request;
910

1011
if ( is_activitypub_request() || is_feed() ) {
1112
return;
@@ -72,9 +73,12 @@
7273
<?php esc_html_e( 'Copy and paste the Comment URL into the search field of your favorite fediverse app or server.', 'activitypub' ); ?>
7374
</div>
7475
<div class="activitypub-dialog__button-group">
76+
<label for="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>" class="screen-reader-text">
77+
<?php esc_html_e( 'Comment URL', 'activitypub' ); ?>
78+
</label>
7579
<input
7680
aria-readonly="true"
77-
id="profile-handle"
81+
id="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>"
7882
readonly
7983
tabindex="-1"
8084
type="text"
@@ -96,12 +100,15 @@ class="wp-element-button wp-block-button__link"
96100
<?php esc_html_e( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
97101
</div>
98102
<div class="activitypub-dialog__button-group">
103+
<label for="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>" class="screen-reader-text">
104+
<?php esc_html_e( 'Your Fediverse profile', 'activitypub' ); ?>
105+
</label>
99106
<input
100107
data-wp-bind--aria-invalid="context.isError"
101108
data-wp-bind--value="context.remoteProfile"
102109
data-wp-on--input="actions.updateRemoteProfile"
103110
data-wp-on--keydown="actions.onInputKeydown"
104-
id="remote-profile"
111+
id="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>"
105112
placeholder="<?php esc_attr_e( '@[email protected]', 'activitypub' ); ?>"
106113
type="text"
107114
/>
@@ -143,6 +150,7 @@ class="activitypub-dialog__error"
143150
>
144151
<div class="activitypub-remote-profile" hidden data-wp-bind--hidden="!context.hasRemoteUser">
145152
<a
153+
href=""
146154
class="comment-reply-link activitypub-remote-profile__link"
147155
data-wp-bind--href="state.remoteProfileUrl"
148156
target="_blank"
@@ -176,7 +184,7 @@ class="comment-reply-link activitypub-remote-reply__link"
176184
data-wp-bind--aria-expanded="context.modal.isOpen"
177185
aria-label="<?php esc_attr_e( 'Reply on the Fediverse', 'activitypub' ); ?>"
178186
aria-haspopup="dialog"
179-
aria-controls="modal-heading"
187+
aria-controls="<?php echo esc_attr( $block_id . '-modal-title' ); ?>"
180188
role="button"
181189
tabindex="0"
182190
hidden
@@ -187,6 +195,7 @@ class="comment-reply-link activitypub-remote-reply__link"
187195
<?php
188196
Blocks::render_modal(
189197
array(
198+
'id' => $block_id . '-modal',
190199
'title' => __( 'Remote Reply', 'activitypub' ),
191200
'content' => $modal_content,
192201
)

0 commit comments

Comments
 (0)