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

Commit

Permalink
Move focus to the input field also when the body has focus, that fixe…
Browse files Browse the repository at this point in the history
…s the issue in Chrome
  • Loading branch information
Aljullu committed May 15, 2023
1 parent 4d75aa3 commit 137770b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assets/js/base/components/quantity-selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@ const QuantitySelector = ( {
) {
return;
}

const currentDocument = inputRef.current.ownerDocument;
if (
! canDecrease &&
decreaseButtonRef.current ===
decreaseButtonRef.current.ownerDocument.activeElement
( currentDocument.activeElement === decreaseButtonRef.current ||
currentDocument.activeElement === currentDocument.body )
) {
inputRef.current.focus();
}
if (
! canIncrease &&
increaseButtonRef.current ===
decreaseButtonRef.current.ownerDocument.activeElement
( currentDocument.activeElement === increaseButtonRef.current ||
currentDocument.activeElement === currentDocument.body )
) {
inputRef.current.focus();
}
Expand Down

0 comments on commit 137770b

Please sign in to comment.