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

fix(acessibility): the favorite button does not have an accessible name #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions messages/context.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"store/wishlist.addButton": "store/wishlist.addButton",
"store/wishlist.removeButton": "store/wishlist.removeButton",
"store/wishlist-see-lists": "store/wishlist-see-lists",
"store/wishlist-product-added-to-list": "store/wishlist-product-added-to-list",
"store/wishlist-add-product-fail": "store/wishlist-add-product-fail",
Expand Down
1 change: 1 addition & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"store/wishlist.addButton": "Add to List",
"store/wishlist.removeButton": "Remove from List",
"store/wishlist-see-lists": "View lists",
"store/wishlist-product-added-to-list": "Product added to the list",
"store/wishlist-add-product-fail": "Couldn't add product to the list",
Expand Down
1 change: 1 addition & 0 deletions messages/es.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"store/wishlist.addButton": "Agregar a la lista",
"store/wishlist.removeButton": "Quitar de la lista",
"store/wishlist-see-lists": "Ver listas",
"store/wishlist-product-added-to-list": "Producto agregado a la lista",
"store/wishlist-add-product-fail": "No se pudo agregar el producto a la lista",
Expand Down
1 change: 1 addition & 0 deletions messages/pt.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"store/wishlist.addButton": "Adicionar aos favoritos",
"store/wishlist.removeButton": "Remover dos favoritos",
"store/wishlist-see-lists": "Ver listas",
"store/wishlist-product-added-to-list": "Produto adicionado à sua lista",
"store/wishlist-add-product-fail": "Não foi possível adicionar o produto",
Expand Down
16 changes: 13 additions & 3 deletions react/AddProductBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const messages: {
defaultMessage: '',
id: 'store/wishlist.addButton',
},
removeButton: {
defaultMessage: '',
id: 'store/wishlist.removeButton',
},
seeLists: {
defaultMessage: '',
id: 'store/wishlist-see-lists',
Expand Down Expand Up @@ -158,7 +162,7 @@ const AddBtn: FC<AddBtnProps> = ({ toastURL = '/account/#wishlist' }) => {
const sessionResponse: any = useSessionResponse()
const [handleCheck, { data, loading, called }] = useLazyQuery(checkItem)
const { data: profileData } = useQuery(profile, {
ssr: false
ssr: false,
})

const [productId] = String(product?.productId).split('-')
Expand Down Expand Up @@ -220,7 +224,9 @@ const AddBtn: FC<AddBtnProps> = ({ toastURL = '/account/#wishlist' }) => {
isAuthenticated =
sessionResponse?.namespaces?.profile?.isAuthenticated?.value === 'true'

shopperId = !profileData?.profile?.pii? sessionResponse?.namespaces?.profile?.email?.value : sessionResponse?.namespaces?.profile?.id?.value?? null
shopperId = !profileData?.profile?.pii
? sessionResponse?.namespaces?.profile?.email?.value
: sessionResponse?.namespaces?.profile?.id?.value ?? null

localStore.setItem(
'wishlist_isAuthenticated',
Expand Down Expand Up @@ -387,7 +393,11 @@ const AddBtn: FC<AddBtnProps> = ({ toastURL = '/account/#wishlist' }) => {
className={`${handles.wishlistIcon} ${
checkFill() ? styles.fill : styles.outline
} ${styles.iconSize}`}
/>
>
{checkFill()
? intl.formatMessage({ id: 'store/wishlist.removeButton' })
: intl.formatMessage({ id: 'store/wishlist.addButton' })}
</span>
</Button>
</div>
</NoSSR>
Expand Down
4 changes: 4 additions & 0 deletions react/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.wishlistIcon {
font-size: 0;
}

.iconSize {
display: inline-block;
width: 24px;
Expand Down