Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings-UI: fix add profile accessibility #19757

Merged
merged 2 commits into from
Feb 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/js/src/settings/routes/site-representation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { addLinkToString } from "../../helpers/stringHelpers";
import { FieldsetLayout, FormikMediaSelectField, FormikUserSelectField, FormikWithErrorField, FormLayout, RouteLayout } from "../components";
import { withFormikDummyField } from "../hocs";
import { useSelectSettings } from "../hooks";
import { useCallback } from "@wordpress/element";

const FormikWithErrorFieldWithDummy = withFormikDummyField( FormikWithErrorField );

Expand Down Expand Up @@ -44,6 +45,11 @@ const SiteRepresentation = () => {
const mastodonPremiumLink = useSelectSettings( "selectLink", [], "https://yoa.st/get-mastodon-integration" );
const mastodonUrlLink = useSelectSettings( "selectLink", [], "https://yoa.st/site-representation-mastodon" );

const handleAddProfile = useCallback( async( arrayHelpers ) => {
igorschoester marked this conversation as resolved.
Show resolved Hide resolved
await arrayHelpers.push( "" );
document.getElementById( `input-wpseo_social-other_social_urls-${ otherSocialUrls.length }` )?.focus();
igorschoester marked this conversation as resolved.
Show resolved Hide resolved
}, [ otherSocialUrls ] );

return (
<RouteLayout
title={ __( "Site representation", "wordpress-seo" ) }
Expand Down Expand Up @@ -241,14 +247,16 @@ const SiteRepresentation = () => {
// eslint-disable-next-line react/jsx-no-bind
onClick={ arrayHelpers.remove.bind( null, index ) }
className="yst-mt-7 yst-p-2.5"
// translators: %1$s expands to array index + 1.
aria-label={ sprintf( __( "Remove Other profile %1$s", "wordpress-seo" ), index + 1 ) }
igorschoester marked this conversation as resolved.
Show resolved Hide resolved
>
<TrashIcon className="yst-h-5 yst-w-5" />
</Button>
</div>
</Transition>
) ) }
{ /* eslint-disable-next-line react/jsx-no-bind */ }
<Button id="button-add-social-profile" variant="secondary" onClick={ arrayHelpers.push.bind( null, "" ) }>
<Button id="button-add-social-profile" variant="secondary" onClick={ ()=>handleAddProfile( arrayHelpers ) }>
igorschoester marked this conversation as resolved.
Show resolved Hide resolved
<PlusIcon className="yst--ml-1 yst-mr-1 yst-h-5 yst-w-5 yst-text-slate-400" />
{ __( "Add another profile", "wordpress-seo" ) }
</Button>
Expand Down