Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Work-around issue with disabled buttons causing lose of focus inside …
Browse files Browse the repository at this point in the history
…the Mini-Cart drawer
  • Loading branch information
Aljullu committed May 11, 2023
1 parent 9b22aae commit 351a216
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions assets/js/base/components/quantity-selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ const QuantitySelector = ( {
),
itemName
) }
className="wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus"
disabled={ disabled || ! canDecrease }
className={ classNames(
'wc-block-components-quantity-selector__button',
'wc-block-components-quantity-selector__button--minus',
{ 'is-disabled': disabled || ! canDecrease }
) }
onClick={ () => {
const newQuantity = quantity - step;
onChange( newQuantity );
Expand All @@ -211,6 +214,8 @@ const QuantitySelector = ( {
);
normalizeQuantity( newQuantity );
} }
aria-disabled={ disabled || ! canDecrease }
tabIndex={ disabled || ! canDecrease ? -1 : undefined }
>
-
</button>
Expand All @@ -223,8 +228,11 @@ const QuantitySelector = ( {
),
itemName
) }
disabled={ disabled || ! canIncrease }
className="wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus"
className={ classNames(
'wc-block-components-quantity-selector__button',
'wc-block-components-quantity-selector__button--plus',
{ 'is-disabled': disabled || ! canIncrease }
) }
onClick={ () => {
const newQuantity = quantity + step;
onChange( newQuantity );
Expand All @@ -240,6 +248,8 @@ const QuantitySelector = ( {
);
normalizeQuantity( newQuantity );
} }
aria-disabled={ disabled || ! canIncrease }
tabIndex={ disabled || ! canIncrease ? -1 : undefined }
>
&#65291;
</button>
Expand Down
2 changes: 1 addition & 1 deletion assets/js/base/components/quantity-selector/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
&:focus {
opacity: 1;
}
&:disabled {
&.is-disabled {
box-shadow: none;
cursor: default;
opacity: 0.6;
Expand Down

0 comments on commit 351a216

Please sign in to comment.