Commit dc5583ebe73 for woocommerce
commit dc5583ebe734d9d4395e3fe8b6a5c2fa75dbaa08
Author: Luigi Teschio <gigitux@gmail.com>
Date: Wed Nov 18 09:51:32 2026 +0100
Fix keyboard accessibility of product attribute removal (#71043)
* Fix keyboard accessibility of product attribute removal
* Add changelog for product attribute removal accessibility
diff --git a/plugins/woocommerce/changelog/fix-attribute-remove-button b/plugins/woocommerce/changelog/fix-attribute-remove-button
new file mode 100644
index 00000000000..94341dcb893
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-attribute-remove-button
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Make the product attribute Remove control accessible as a button, supporting Enter and Space keys.
diff --git a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
index 9d4177c6392..7e59a85c73f 100644
--- a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
+++ b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
@@ -920,6 +920,24 @@ jQuery( function ( $ ) {
}
);
+ // Links already support Enter, but role="button" does not add Space-key support.
+ // Prevent Space from scrolling and activate on keyup, as native buttons do.
+ $( '#product_attributes' ).on(
+ 'keydown keyup',
+ '.product_attributes a.remove_row[role="button"]',
+ function ( event ) {
+ if ( event.key !== ' ' ) {
+ return;
+ }
+
+ event.preventDefault();
+
+ if ( event.type === 'keyup' ) {
+ this.click();
+ }
+ }
+ );
+
$( '#product_attributes' ).on(
'click',
'.product_attributes .remove_row',
diff --git a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php
index 618d5b31042..4afb7e316e2 100644
--- a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php
+++ b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php
@@ -10,7 +10,7 @@ if ( ! isset( $attribute ) ) {
<h3>
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div>
<div class="tips sort" data-tip="<?php esc_attr_e( 'Drag and drop to set admin attribute order', 'woocommerce' ); ?>"></div>
- <a href="#" class="remove_row delete"><?php esc_html_e( 'Remove', 'woocommerce' ); ?></a>
+ <a href="#" class="remove_row delete" role="button"><?php esc_html_e( 'Remove', 'woocommerce' ); ?></a>
<strong class="attribute_name<?php echo esc_attr( $attribute->get_name() === '' ? ' placeholder' : '' ); ?>"><?php echo esc_html( $attribute->get_name() !== '' ? wc_attribute_label( $attribute->get_name() ) : __( 'New attribute', 'woocommerce' ) ); ?></strong>
<?php if ( $attribute->is_taxonomy() ) : ?>
<?php