From c796152bdd65a68387b3115974cb4e617ba2d5c6 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 20 Jul 2024 06:54:53 +0700 Subject: [PATCH] Focus the other button when reaching the beginning/end --- src/web-components/bx-select.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/web-components/bx-select.ts b/src/web-components/bx-select.ts index 1bcbcb0..45c2fa0 100644 --- a/src/web-components/bx-select.ts +++ b/src/web-components/bx-select.ts @@ -97,10 +97,11 @@ export class BxSelectElement { const disableNext = visibleIndex === $select.querySelectorAll('option').length - 1; $btnPrev.classList.toggle('bx-inactive', disablePrev); - // disablePrev && document.activeElement === $btnPrev && $btnNext.focus(); - $btnNext.classList.toggle('bx-inactive', disableNext); - // disableNext && document.activeElement === $btnNext &&$btnPrev.focus(); + + // Focus the other button when reaching the beginning/end + disablePrev && !disableNext && document.activeElement === $btnPrev && $btnNext.focus(); + disableNext && !disablePrev && document.activeElement === $btnNext && $btnPrev.focus(); } const normalizeIndex = (index: number): number => {