diff --git a/packages/components/pagination/src/components/pager.vue b/packages/components/pagination/src/components/pager.vue index fd4f71901c..b9cb6d3f75 100644 --- a/packages/components/pagination/src/components/pager.vue +++ b/packages/components/pagination/src/components/pager.vue @@ -20,10 +20,13 @@ nsIcon.b(), nsPager.is('disabled', disabled), ]" - @mouseenter="onMouseenter('left')" + tabindex="0" + @mouseenter="onMouseEnter(true)" @mouseleave="quickPrevHover = false" + @focus="onFocus(true)" + @blur="quickPrevFocus = false" > - +
  • - +
  • { const pagerCount = props.pagerCount const halfPagerCount = (pagerCount - 1) / 2 @@ -133,14 +141,21 @@ watchEffect(() => { } } }) -function onMouseenter(direction: 'left' | 'right') { +function onMouseEnter(forward = false) { if (props.disabled) return - if (direction === 'left') { + if (forward) { quickPrevHover.value = true } else { quickNextHover.value = true } } +function onFocus(forward = false) { + if (forward) { + quickPrevFocus.value = true + } else { + quickNextFocus.value = true + } +} function onEnter(e: UIEvent) { const target = e.target as HTMLElement if ( @@ -151,6 +166,11 @@ function onEnter(e: UIEvent) { if (newPage !== props.currentPage) { emit('change', newPage) } + } else if ( + target.tagName.toLowerCase() === 'li' && + Array.from(target.classList).includes('more') + ) { + onPagerClick(e) } } function onPagerClick(event: UIEvent) { diff --git a/packages/theme-chalk/src/pagination.scss b/packages/theme-chalk/src/pagination.scss index d4fcc72ee4..a8c7f1fd7c 100644 --- a/packages/theme-chalk/src/pagination.scss +++ b/packages/theme-chalk/src/pagination.scss @@ -94,6 +94,11 @@ font-weight: bold; width: inherit; } + + &:focus-visible { + outline: 1px solid getCssVar('pagination-hover-color'); + color: getCssVar('pagination-hover-color'); + } } .#{$namespace}-pager li.is-disabled { @@ -323,6 +328,11 @@ svg { pointer-events: none; } + + &:focus-visible { + outline: 1px solid getCssVar('pagination-hover-color'); + color: getCssVar('pagination-hover-color'); + } } &.is-active + li {