Skip to content
Prev Previous commit
Next Next commit
JS Lint fixes
  • Loading branch information
karthick-murugan committed Sep 25, 2025
commit 7fa4066929b1d5a06f20ef6d5ce5cda0cd4d353b
6 changes: 2 additions & 4 deletions packages/editor/src/components/collab-sidebar/add-comment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { _x } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import {
__experimentalHStack as HStack,
Expand Down Expand Up @@ -53,9 +53,7 @@ export function AddComment( {
return null;
}

// Generate contextual label for new comment
// For new comments, use a generic label since we don't have an ID yet
const commentLabel = _x( 'New Comment', 'Add new comment label' );
const commentLabel = __( 'New Comment' );

return (
<VStack
Expand Down
17 changes: 6 additions & 11 deletions packages/editor/src/components/collab-sidebar/comment-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import TextareaAutosize from 'react-autosize-textarea';
import { useState } from '@wordpress/element';
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
Button,
VisuallyHidden,
} from '@wordpress/components';
import { _x, __ } from '@wordpress/i18n';
import { useInstanceId } from '@wordpress/compose';
Expand All @@ -30,7 +30,6 @@ import { sanitizeCommentString } from './utils';
* @param {string} props.submitButtonText - The text to display on the submit button.
* @param {string?} props.placeholderText - The placeholder text for the comment input.
* @param {number?} props.rows - The number of rows for the comment input.
* @param {string?} props.labelText - Custom label text for accessibility.
* @return {React.ReactNode} The CommentForm component.
*/
function CommentForm( {
Expand All @@ -40,7 +39,6 @@ function CommentForm( {
submitButtonText,
placeholderText,
rows = 4,
labelText,
} ) {
const [ inputComment, setInputComment ] = useState(
thread?.content?.raw ?? ''
Expand All @@ -49,13 +47,10 @@ function CommentForm( {
const inputId = useInstanceId( CommentForm, 'comment-input' );

return (
<VStack spacing="3">
<label
htmlFor={ inputId }
className="editor-collab-sidebar-panel__comment-label"
>
{ labelText || __( 'Comment' ) }
</label>
<>
<VisuallyHidden as="label" htmlFor={ inputId }>
{ __( 'Comment' ) }
</VisuallyHidden>
<TextareaAutosize
id={ inputId }
value={ inputComment ?? '' }
Expand Down Expand Up @@ -87,7 +82,7 @@ function CommentForm( {
text={ _x( 'Cancel', 'Cancel comment button' ) }
/>
</HStack>
</VStack>
</>
);
}

Expand Down
35 changes: 2 additions & 33 deletions packages/editor/src/components/collab-sidebar/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,6 @@ function Thread( {
id={ thread.id }
spacing="3"
onClick={ () => handleCommentSelect( thread ) }
onKeyDown={ ( event ) => {
if ( event.key === 'Enter' || event.key === ' ' ) {
event.preventDefault();
handleCommentSelect( thread.id );
}
} }
role="button"
tabIndex={ 0 }
aria-label={ sprintf(
// translators: %1$s: comment identifier, %2$s: author name, %3$s: reply count, %4$s: status, %5$s: date.
_x(
'Comments dialog. Open comment %1$s. Author %2$s. %3$s replies. Status: %4$s. Posted %5$s. Click to focus.',
'Comment accessibility label with full context'
),
thread.id,
thread?.author_name || 'Unknown',
thread?.replies?.length || 0,
thread?.status === 'approved' ? 'resolved' : 'active',
thread?.date
? new Date( thread.date ).toLocaleDateString()
: 'unknown date'
) }
{ ...( thread?.replies?.length > 0 && {
'aria-expanded': isFocused,
} ) }
>
<CommentBoard
thread={ thread }
Expand Down Expand Up @@ -256,10 +231,7 @@ function Thread( {
rows={ 'approved' === thread.status ? 2 : 4 }
labelText={ sprintf(
// translators: %1$s: comment identifier, %2$s: author name
_x(
'Reply to Comment %1$s by %2$s',
'Reply to specific comment with author context'
),
__( 'Reply to Comment %1$s by %2$s' ),
thread.id,
thread?.author_name || 'Unknown'
) }
Expand Down Expand Up @@ -390,10 +362,7 @@ const CommentBoard = ( {
submitButtonText={ _x( 'Update', 'verb' ) }
labelText={ sprintf(
// translators: %1$s: comment identifier, %2$s: author name.
_x(
'Edit Comment %1$s by %2$s',
'Edit specific comment with author context'
),
__( 'Edit Comment %1$s by %2$s' ),
thread.id,
thread?.author_name || 'Unknown'
) }
Expand Down
Loading