Skip to content

Commit 9613b53

Browse files
committed
fix: address PR review comments
- Remove unused @wordpress/i18n import - Fix aria-describedby ID mismatch for accessibility - Fix double translation of tipMessage - Fix platform-specific path separators in tests - Remove no-op onChange handler - Replace hard-coded colors with design-system tokens - Optimize resolveDefaultSiteDirectory calls - Add error handling for loadUserData
1 parent d452014 commit 9613b53

File tree

5 files changed

+788
-785
lines changed

5 files changed

+788
-785
lines changed
Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { __ } from '@wordpress/i18n';
21
import { useI18n } from '@wordpress/react-i18n';
32
import FolderIcon from 'src/components/folder-icon';
43
import { cx } from 'src/lib/cx';
@@ -12,18 +11,18 @@ export interface FormPathInputComponentProps {
1211
id?: string;
1312
}
1413

15-
export function FormPathInputComponent( {
14+
export function FormPathInputComponent({
1615
value,
1716
onClick,
1817
error,
1918
doesPathContainWordPress,
2019
id,
21-
}: FormPathInputComponentProps ) {
20+
}: FormPathInputComponentProps) {
2221
const { __ } = useI18n();
2322
return (
2423
<div className="flex flex-col gap-2">
2524
<button
26-
aria-invalid={ !! error }
25+
aria-invalid={!!error}
2726
/**
2827
* The below `aria-describedby` presumes the error message always
2928
* relates to the local path input, which is true currently as it is the
@@ -32,41 +31,36 @@ export function FormPathInputComponent( {
3231
* `aria-describedby` attribute so that it only targets relevant error
3332
* messages.
3433
*/
35-
aria-describedby={ error ? 'site-path-error' : undefined }
34+
aria-describedby={error ? 'site-path-error' : undefined}
3635
type="button"
37-
aria-label={ `${ value }, ${ __( 'Select different local path' ) }` }
38-
className={ cx(
39-
'flex flex-row items-stretch rounded-sm border border-[#949494] focus:border-a8c-blue-50 focus:shadow-[0_0_0_0.5px_black] focus:shadow-a8c-blue-50 outline-none transition-shadow transition-linear duration-100 [&_.local-path-icon]:focus:border-l-a8c-blue-50 [&:disabled]:cursor-not-allowed',
36+
aria-label={`${value}, ${__('Select different local path')}`}
37+
className={cx(
38+
'flex flex-row items-stretch rounded-sm border border-frame-border focus:border-frame-theme focus:shadow-[0_0_0_0.5px] focus:shadow-a8c-blue-50 outline-none transition-shadow transition-linear duration-100 [&_.local-path-icon]:focus:border-l-frame-theme [&:disabled]:cursor-not-allowed',
4039
error && 'border-red-500 [&_.local-path-icon]:border-l-red-500'
41-
) }
40+
)}
4241
data-testid="select-path-button"
43-
onClick={ onClick }
44-
id={ id }
42+
onClick={onClick}
43+
id={id}
4544
>
46-
<div
47-
aria-hidden="true"
48-
tabIndex={ -1 }
49-
className="w-full text-left pl-3 py-3 min-h-10"
50-
onChange={ () => {} }
51-
>
52-
{ value }
45+
<div aria-hidden="true" tabIndex={-1} className="w-full text-left pl-3 py-3 min-h-10">
46+
{value}
5347
</div>
5448
<div
5549
aria-hidden="true"
5650
className="local-path-icon flex items-center py-[9px] px-2.5 self-center"
5751
>
58-
<FolderIcon className="text-[#3C434A]" />
52+
<FolderIcon className="text-frame-text-secondary" />
5953
</div>
6054
</button>
6155
<SiteFormError
62-
error={ error }
56+
error={error}
6357
tipMessage={
6458
doesPathContainWordPress
65-
? __( 'The existing WordPress site at this path will be added.' )
59+
? __('The existing WordPress site at this path will be added.')
6660
: ''
6761
}
6862
/>
69-
<input type="hidden" data-testid="local-path-input" value={ value } />
63+
<input type="hidden" data-testid="local-path-input" value={value} />
7064
</div>
7165
);
7266
}

apps/studio/src/components/site-form-error.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Icon } from '@wordpress/components';
2-
import { __ } from '@wordpress/i18n';
32
import { cautionFilled, tip } from '@wordpress/icons';
43
import { cx } from 'src/lib/cx';
54

@@ -9,26 +8,26 @@ export interface SiteFormErrorProps {
98
className?: string;
109
}
1110

12-
export const SiteFormError = ( { error, tipMessage = '', className = '' }: SiteFormErrorProps ) => {
11+
export const SiteFormError = ({ error, tipMessage = '', className = '' }: SiteFormErrorProps) => {
1312
return (
14-
( error || tipMessage ) && (
13+
(error || tipMessage) && (
1514
<div
16-
id={ error ? 'error-message' : 'tip-message' }
15+
id="site-path-error"
1716
role="alert"
1817
aria-atomic="true"
19-
className={ cx(
18+
className={cx(
2019
'flex items-start gap-1 text-xs',
21-
error ? 'text-red-500' : 'text-a8c-gray-50',
20+
error ? 'text-red-500' : 'text-frame-text-secondary',
2221
className
23-
) }
22+
)}
2423
>
2524
<Icon
26-
className={ cx( 'shrink-0 basis-4', error ? 'fill-red-500' : 'fill-a8c-gray-50' ) }
27-
icon={ error ? cautionFilled : tip }
28-
width={ 16 }
29-
height={ 16 }
25+
className={cx('shrink-0 basis-4', error ? 'fill-red-500' : 'fill-frame-text-secondary')}
26+
icon={error ? cautionFilled : tip}
27+
width={16}
28+
height={16}
3029
/>
31-
<p>{ error ? error : __( tipMessage ) }</p>
30+
<p>{error ? error : tipMessage}</p>
3231
</div>
3332
)
3433
);

0 commit comments

Comments
 (0)